设置 div 高度为自动并启用滚动

5
<div style='width: 240px; height:530px; overflow:scroll;'>
<table>
bla.. bla..
</table>
</div>

亲们,我想要自动设置此div的高度,但是当我将其更改为height:auto;时,表格中的数据不能滚动。
有人有建议吗?
谢谢。
3个回答

3
<div style='width: 240px; min-height:530px; overflow:scroll;'>
<table>
bla.. bla..
</table>
</div>

2

你可以使用 min-heightmax-height 属性,如果超过了 max-height 属性的高度限制,就会出现滚动条。


1
<div style='width: 240px; height:530px; overflow-y: auto;'>

<table>
bla.. bla..

</table>

</div>

如果我们需要同时出现X和Y滚动条,可以使用另一种选项overflow: auto;


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接