How to fix the table height?

独自空忆成欢 提交于 2020-01-03 07:32:08

问题


I want to fix the table height to 600px, eve if the content goes long.


回答1:


Try wrapping the table within a div tag, and setting the CSS properties of the div like so:

div.tablewrapper {
    height: 600px;
    overflow-y: auto;
}

This will make a scrollbar appear if the table's height exceeds 600 pixels. If you don't want to always force the height to 600px if the table it too small to take up that much space, but instead just want 600px to be the max, use max-height instead of height.




回答2:


div.tablewrapper {
    height: 600px;
    overflow-y:hidden;
}

this works for to fix a page exact 600px as height..




回答3:


See the sample code below..

<div style="height:100px; overflow:auto;">
<table>
    <tr>
        <td>sad<br />
<br />
<br />
<br />
<br />
<br />
<br /><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
asd<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />

</td>
</tr>
</table>
</div>


来源:https://stackoverflow.com/questions/1754136/how-to-fix-the-table-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!