【发布时间】:2016-08-17 09:17:44
【问题描述】:
我有一个以表格格式显示数据的网格视图。我必须使表头变粘。所以使用一些 js 代码,我生成了表头的副本。我正在使用该副本显示为粘性标题(当用户滚动此标题时将显示)。
原始网格是自动生成的(我使用的是 Yii)。
table.items {
background: white;
border-collapse: collapse;
width: 100%;
border: 1px #D0E3EF solid;
}
<table class="items">
<thead style="display: block;">
<tr>
<th id="property-grid-current_c0" style="width:46.1px !important;border-right:1px solid #000">Watch</th>
<th class="" colspan="2" style="display: none;width:18.1px !important;border-right:1px solid #000" id="property-grid-current_c1"> </th>
<th class="" colspan="2" id="property-grid-current_c2" style="width:261px !important;border-right:1px solid #000">Property Name</th>
<th id="property-grid-current_c3" style="width:86px !important;border-right:1px solid #000">SVP</th>
</tr>
</thead>
</table>
现在的问题是隐藏 td 的宽度对表格宽度没有影响。那么如何解决呢?
【问题讨论】: