<div style='width: 240px; height:530px; overflow:scroll;'>
<table>
bla.. bla..
</table>
</div>
亲们,我想要自动设置此div的高度,但是当我将其更改为height:auto;时,表格中的数据不能滚动。
有人有建议吗?
谢谢。
<div style='width: 240px; height:530px; overflow:scroll;'>
<table>
bla.. bla..
</table>
</div>
<div style='width: 240px; min-height:530px; overflow:scroll;'>
<table>
bla.. bla..
</table>
</div>
你可以使用 min-height 和 max-height 属性,如果超过了 max-height 属性的高度限制,就会出现滚动条。
<div style='width: 240px; height:530px; overflow-y: auto;'>
<table>
bla.. bla..
</table>
</div>
如果我们需要同时出现X和Y滚动条,可以使用另一种选项overflow: auto;