固定table的表頭CSS&JQuery

來源:互聯網
上載者:User

標籤:

対応ブラウザのバージョン
  • Internet Explorer 9 / 10 / 11
  • Firefox 29
  • Google Chrome 34
  • Safari 5
  • Opera 12
表頭固定的方法

<table class="table-design tablelock1">
<thead>
<tr>
<th>TableHeader1</th><th>TableHeader2</th>
<th>TableHeader3</th><th>TableHeader4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Contents1</td><td>Contents2</td>
<td>Contents3</td><td>Contents4</td>
</tr>
<tr>
<td>Contents5</td><td>Contents6</td>
<td>Contents7</td><td>Contents8</td>
</tr>
<tr>
<td>Contents9</td><td>Contents10</td>
<td>Contents11</td><td>Contents12</td>
</tr>
</tbody>
</table>

.table-design{
border-collapse: collapse;
border: 1px solid #666;
text-align: center;
vertical-align: middle;
margin-bottom:30px;
}
.table-design th{
background: #ccc;
border:1px solid #aaa;
padding:25px 5px;
}
.table-design td{
border:1px solid #aaa;
padding:25px 5px;
}

  • 方法一 CSS固定

.tablelock1 thead{
display:block;
width:482px; /* 500px - スクロールバー */
}
.tablelock1 tbody{
overflow-x: hidden;
overflow-y: auto;
-ms-overflow-x: hidden;
-ms-overflow-y: auto;
position: absolute;
display:block;
height: 100px;
width:500px;
}
.tablelock1 th
,.tablelock1 td
{
width: 110px;
}

 

 

 

內容來源

http://webnonotes.com/css/table-header/

固定table的表頭CSS&JQuery

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.