CSS,Header-Absolute,向下滚动

时间:2015-02-18 12:01:00

标签: javascript html css

我需要(表格标题)在顶部然后我向下滚动  列表,标题保留在页面顶部(不在左侧)。 我试图编辑CSS,但可能是它的HTML错误? HTML

    <div class="outer">
  <div class="inner">
    <table>
        <tr>
          <th>Header A</th>
          <td>col 1 - A</td>
          <td>col 2 - A (WITH LONGER CONTENT)</td>
          <td>col 3 - A</td>
          <td>col 4 - A</td>
          <td>col 5 - A</td>
        </tr>
        <tr>
          <th>Header B</th>
          <td>col 1 - B</td>
          <td>col 2 - B</td>
          <td>col 3 - B</td>
          <td>col 4 - B</td>
          <td>col 5 - B</td>
        </tr>
        <tr>
          <th>Header C</th>
          <td>col 1 - C</td>
          <td>col 2 - C</td>
          <td>col 3 - C</td>
          <td>col 4 - C</td>
          <td>col 5 - C</td>
        </tr>
    </table>
  </div>
</div>

CSS:

table {
  table-layout: fixed; 
  width: 100%;
  *margin-left: -100px;/*ie7*/
}
td, th {
  vertical-align: top;
  border-top: 1px solid #ccc;
  padding:10px;
  width:100px;
}
th {
  position:absolute;
  *position: relative; /*ie7*/
  left:0; 
  width:100px;
}
.outer {position:relative}
.inner {
  overflow-x:scroll;
  overflow-y:visible;
  width:400px; 
  margin-left:100px;
}

2 个答案:

答案 0 :(得分:0)

试试这个http://jsfiddle.net/5PFak/71/

change some layout of your table.

答案 1 :(得分:0)

看起来它更像是一个CSS问题,虽然我不确定你是否也以正确的方式编写了HTML。

This thread可以帮助您解决问题。

告诉我它是否不存在,但我确定你会通过尝试修复标题表来找到答案&#34;无论如何,谷歌。