首页 \ 问答 \ 样式浮动表头(Style floating table headers)

样式浮动表头(Style floating table headers)

所以我一直在努力让浮动表头工作。 不幸的是我不能使用像floatThead jQuery库这样的东西,因为我需要在滚动表格时悬停不同的行,所以我基于各种其他SO答案提出了我自己的解决方案。

但是,问题是浮动标题的样式与非浮动标题的样式不匹配,我不确定为什么是这样或正确的方法来解决这个问题。

这是一个说明我当前代码的jsFiddle 。 问题是具有不同列的第一个浮动标头与非浮动标头的大小不匹配,即使它们都具有百分比宽度(加起来为100%)。

重要的javascript:

var persist = $(".persist-area");
var z_index = 900;
var count = 0;
persist.each(function() {
    var el = $(".persist-thead>tr", this);
    el.before(el.clone()).css({"width": el.width(), "top": "0px", "z-index": "899"}).addClass('floating-thead');
    $(".persist-header", this).each(function() {
        var clone = $(this);
        clone.before(clone.clone()).css({
            "width": clone.width(),
            "top": (0 + el.height()) + "px",
            "z-index": "" + z_index
        }).addClass("floating-header").removeClass("persist-header").attr('id', 'floating-header-' + count);
        z_index++;
        count++;
    });
});

和css:

.floating-thead,
.floating-header {
    position: fixed;
    top: 0;
    visibility: hidden;
}

.floating-thead > td,
.floating-header > td {
    display: inline-block;
    text-align: center;
}

So I've been trying to accomplish getting floating table headers to work. Unfortunately I cannot use something like floatThead jQuery library as I need to hover different rows as you scroll through the table so I've come up with my own solution based on various other SO answers.

However, the problem is that the styling of the floating header does not match the styling of the non-floated header and I'm not sure why that is or the proper way to fix this.

Here's a jsFiddle illustrating my current code. The issue is that the first floating header which has different columns does not match the sizing of the non-floating header even though they both have percentage widths (that add up to 100%).

The important javascript:

var persist = $(".persist-area");
var z_index = 900;
var count = 0;
persist.each(function() {
    var el = $(".persist-thead>tr", this);
    el.before(el.clone()).css({"width": el.width(), "top": "0px", "z-index": "899"}).addClass('floating-thead');
    $(".persist-header", this).each(function() {
        var clone = $(this);
        clone.before(clone.clone()).css({
            "width": clone.width(),
            "top": (0 + el.height()) + "px",
            "z-index": "" + z_index
        }).addClass("floating-header").removeClass("persist-header").attr('id', 'floating-header-' + count);
        z_index++;
        count++;
    });
});

and css:

.floating-thead,
.floating-header {
    position: fixed;
    top: 0;
    visibility: hidden;
}

.floating-thead > td,
.floating-header > td {
    display: inline-block;
    text-align: center;
}

原文:https://stackoverflow.com/questions/39665883
更新时间:2023-09-12 19:09

最满意答案

这是一个棘手的问题。

浮点格式定义了一些特殊值。 您是否将这些视为不同取决于您的观点。 以下是双精度(binary64):

  1. 有两个0的表示:符号位0或1,指数和尾数都为零。 这些值可通过1 / + 0 =无穷大和1 / -0 = -infinity的事实来区分。 但他们比较平等。
  2. 有2个无穷大,其中前12位是0x7ff或0xfff,尾数全为零。 这些不是有限的实数,但它们是值。
  3. 存在整个范围的非数字(NaN)值,具有符号+指数位0x7ff(信令NaN)或0xfff(“安静”NaN)和非零尾数。 同样,这些不是实数,但它们是可区分的值。

所以,总结一下:

  1. 可区分值的总数(实数或其他)是2 ^ 64。
  2. 不包括无穷大且仅计数零一次的不同实数的数量是2*(2^11-1)*2^52-1 = 18,437,736,874,454,810,623

对于binary16,不同实数的数量是2*(2^5-1)*2^10-1 = 63,487 。 对于binary32,它是2*(2^8-1)*2^23-1=4,278,190,079 。 对于binary128,它是2*(2^15-1)*2^112-1或大约3.4*10^38


This is a trick question.

The floating-point formats define some special values. Whether you count these as distinct depends on your point of view. The following is for double-precision (binary64):

  1. There are two representations of 0: with the sign bit 0 or 1 and both the exponent and mantissa all zero. The values are distinguishable by the fact that 1/+0 = infinity and 1/-0 = -infinity. But they compare equal.
  2. There are 2 infinities, where the first 12 bits are 0x7ff or 0xfff and the mantissa is all zero. These are not finite real numbers, but they are values.
  3. There is a whole range of Not-A-Number (NaN) values, having sign+exponent bits 0x7ff (signaling NaN) or 0xfff ("quiet" NaN) and a nonzero mantissa. Again, these are not real numbers but they are distinguishable values.

So, to summarize:

  1. The total number of distinguishable values (real numbers or otherwise) is 2^64.
  2. The number of distinct real numbers, excluding infinities and counting zero only once, is 2*(2^11-1)*2^52-1 = 18,437,736,874,454,810,623.

For binary16, the number of distinct real numbers is 2*(2^5-1)*2^10-1 = 63,487. For binary32, it's 2*(2^8-1)*2^23-1=4,278,190,079. For binary128, it's 2*(2^15-1)*2^112-1 or about 3.4*10^38.

相关问答

更多
  • 当英特尔开始创建8087数学协处理器时,加州大学伯克利分校的教授William Kahan已经完成了IEEE-754浮点标准的工作。 成为IEEE-754浮点格式的设计标准之一是尽可能与现有专有浮点格式的功能兼容性。 这本书 John F. Palmer和Stephen P. Morse,“8087 Primer”。 Wiley,纽约1984。 特别提到了CDC 6600的60位浮点格式,相对于双精度格式,具有11位指数和48位尾数。 以下公布的访谈(令人费解地将Jerome Coonen的名字改为Gero ...
  • 不要使用2^16-1 。 使用2^16 。 是的,你的精度会略微降低并浪费你的0xFFFF ,但你会保证在转换到浮点时不会有精度损失。 (相反,当从浮点转换时,您将失去8位的mantissal精度。) 精度之间的往返转换可能导致某些操作出现问题,特别是逐步求和数字。 如果可能的话,将定点值视为“脏”,不要将它们用于进一步的浮点计算; 更喜欢从输入重新计算到使用定点形式的中间结果。 或者,使用24位。 使用此表示,只要您的值不下溢(即,只要它们高于2^-24 ),您就不会在任何方向上失去任何精度。 Don't ...
  • 是的,这将永远为真,没有数字解释的位模式,运算符==将不会返回完全相反的!=。 对于不同的位模式(负零点0x80 ...等于零0x00 ...)进行比较的位模式有异常,或者与您已经提到的相同的位模式比较为不等(NaN),但是!=总是==的反转。 Yes, this will be always true, there are no number interpretations of bit patterns for which the operator == will not return the exac ...
  • 你可以使用struct.unpack 。 >d是big-endian double; 请参阅help(struct)了解更多信息! import struct d, = struct.unpack('>d', b'\xc0\x6f\xca\x5e\x35\x00\x00\x00') print(d) # -254.32399988174438 如果您的字符串确实是'C06FCA5E35000000' ,则可以使用binascii.a2b_hex将其首先转换为字节。 You can use struct ...
  • 感谢您报告这一点。 我们已经解决了这个问题 ,并且已经与CrateDB 1.1.3(stable)一起发布。 作为一个方面说明: 此改进检查包含算术运算符和小数值的表达式是否仅包含float类型。 如果是这种情况,则结果数据类型将是float类型。 如果表达式包含double类型的十进制值,则行为与之前类似,结果类型也将是double类型的表示形式。 Thanks for reporting this. We fixed this issue already and it has also been rel ...
  • 这是一个棘手的问题。 浮点格式定义了一些特殊值。 您是否将这些视为不同取决于您的观点。 以下是双精度(binary64): 有两个0的表示:符号位0或1,指数和尾数都为零。 这些值可通过1 / + 0 =无穷大和1 / -0 = -infinity的事实来区分。 但他们比较平等。 有2个无穷大,其中前12位是0x7ff或0xfff,尾数全为零。 这些不是有限的实数,但它们是值。 存在整个范围的非数字(NaN)值,具有符号+指数位0x7ff(信令NaN)或0xfff(“安静”NaN)和非零尾数。 同样,这些不 ...
  • isinf ,来自cmath的函数旨在与C语言兼容,需要double 。 传递给该函数时, long double参数会以静默方式转换为double 。 转换为double会根据浮点舍入规则生成+inf (任何大于限制的数字本身略大于DBL_MAX都会舍入为+inf )。 相比之下, std::isinf 过载并且需要很long double 。 当你传递一个long double ,参数不会被转换, std::isinf可以告诉它不是无限的。 要尝试回答您的其他问题: isinf是宏还是函数是一个小细节。 ...
  • 以下内容可能有效: double isbad(double x, double releps) { double y = x * (1 + 0x1.0p29); double z = y-x-y+x; return !(fabs(z/x) < releps); } 这使用了一种技巧(由于Dekker,我相信)将浮点数分成“大半”和“小半”,它们与原始数字完全相加。 我希望“大半”有23位而“小半”有其余的,所以我使用常数1 + 2 ^(52-23)进行分割。 注意事项:您需要通过检查上限和下限 ...
  • 看看这里的sscanf文档,如果你想要一个字符串浮点数,你需要指定格式。 以下是此页面中与您类似的示例: tempString = '78°F 72°F 64°F 66°F 49°F'; degrees = char(176); tempNumeric = sscanf(tempString, ['%d' degrees 'F'])' tempNumeric = 78 72 64 66 49 在您的具体情况下,您可以尝试: val = sscanf(rangedata,' ...
  • 根据定义,有效数是基数β中的p“数字”序列,其中基数β中的数字是β可能值之一,从表示0的数字到表示β-1的数字。 p个数字的序列有多少选择,其中每个数字都有β个可能的值? 答案是βp :第一个数字有β选择,第二个数字有β选择,可以独立于第一个数字选择,依此类推。 例如,可以在β*β或β2值中选择两位数的有效数。 对于一个更具体的例子,在十进制(β= 10)中,有1000个有效数字,长度为3,从000到999.这1000种可能性可以用10位编码,仔细编码(编码4位中的每个十进制数字)不行,但更复杂的东西,因为 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。