相关疑难解决方法(0)

宽度为100%的HTML表格,在tbody中有垂直滚动

如何设置<table>100%宽度并仅在<tbody>垂直滚动内放置一些高度?

tbody里面的垂直滚动

table {
    width: 100%;
    display:block;
}
thead {
    display: inline-block;
    width: 100%;
    height: 20px;
}
tbody {
    height: 200px;
    display: inline-block;
    width: 100%;
    overflow: auto;
}
  
Run Code Online (Sandbox Code Playgroud)
<table>
  <thead>
    <tr>
    	<th>Head 1</th>
    	<th>Head 2</th>
    	<th>Head 3</th>
    	<th>Head 4</th>
    	<th>Head 5</th>
    </tr>
  </thead>
  <tbody>
    <tr>
    	<td>Content 1</td>
    	<td>Content 2</td>
    	<td>Content 3</td>
    	<td>Content 4</td>
    	<td>Content 5</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我希望避免增加一些额外的div,我要的是简单的表像这样,当我试图改变显示table-layout,position在CSS表以及更多的东西没有工作好与100%的宽度仅与PX固定宽度.

html css css3 vertical-scrolling

387
推荐指数
7
解决办法
72万
查看次数

标签 统计

css ×1

css3 ×1

html ×1

vertical-scrolling ×1