这是场景。我有一个填充滚动数据的表格。它包含大量行。并且在每个滚动宽度上th
动态变化。该表是用knockoutjs
. 请在下面找到th
.
<th data-bind="style: { 'min-width': minWidth + 'px', width: width + '%', height: '25px', 'text-align': 'center' }" style="min-width: 20px; width: 9.30232558139535%; height: 25px; text-align: center;">
<div class="headerCell" data-bind="click: click" style="width: 136px;">
<div class="headerText" style="text-align: center;">
<div class="headerName" data-bind="attr:{title: name}, text: name" title="Name">Name</div>
<div style="float: right; margin-top: 10PX; MARGIN-right: 1px;" data-bind="css: { 'arrow-up': sortType() == 'Asc', 'arrow-down': sortType() == 'Desc' }" class=""></div>
</div>
</div>
</th>
的文本th
包含在 a 中div
。类headerCell
和headerText
如下:
.headerCell{
position: absolute;
background: transparent;
line-height: 20px;
top: 0;
margin-left: -1px;
cursor: pointer;
}
.headerText{
left: 0;
margin: 0;
width: 100%;
color: white;
background-color: #333333;
}
现在这里th
仍然存在fixed
,但th
s 与td
of不一致tbody
。有时它对齐,有时它不对齐。这在 Firefox 中可以正常工作。问题出现在 chrome 浏览器中。
我也尝试使用jquery
插件修复它,但它们都不起作用。
动态分配th
宽度时如何解决更改其位置的问题?th