【问题标题】:issue with position:fixed位置问题:固定
【发布时间】:2012-10-04 11:46:39
【问题描述】:

我有一个表结构的以下代码,我尝试冻结它的标题。我已经使用 position:fixed 修复了标题。在这样做的同时,表头会丢失它的列宽,并且在 thead 和 tbody 列宽之间存在不对齐。任何人都可以告诉如何避免这种情况吗??

<div class="outer_div"  style=" width: 1316px;height: 324px;overflow: auto;"> 
<table  class="scrollTable" id="invoiceMeasurement_table"
style="width: 1316pxfloat: left;float: left;width: 1300px;table-layout: fixed;" >   
<thead 
<tr style="position: fixed;margin-top: -10%;width: 1316px;">
<th style="width:75px">Col1</th>
<th style="width:75px">Col2</th>
<th style="width:75px">Col3</th>
<th style="width:91px">Col4</th>
</tr>
</thead>
<tbody >
</tbody>/*tbody is getting generated dynamically */
</table>
</div>

【问题讨论】:

  • 如果我使用 ,标题会固定,但如果我这样使用,标题会在正文滚动时移动。
  • 你能解释一下你到底想在这里实现什么吗?
  • @JamieM23 我需要冻结上述格式表格的标题

标签: css internet-explorer-8


【解决方案1】:

您在 head 标签中使用此代码并删除样式浮动

<!--[if IE 8]>
   <style type="text/css">
     #fixedHeader{
        position:relative !important;
     }
   </style>
<![endif]-->

【讨论】:

  • 也没有运气,但如果我使用 ,标题会得到修复,但如果我这样使用,标题会在正文移动时移动滚动。
  • 您使用此代码并删除所有内部样式 #fixedHeader{ position:relative !important; }
  • 仍然无法正常工作,我使用的表格结构如下所示。您能告诉我如何冻结该表格的标题吗?
  • '
    /*tbody 正在动态生成 */
    Col1 Col2 Col3 Col4
    '
猜你喜欢
相关资源
最近更新 更多
热门标签