设置 max-height 而不是 height 也可以解决问题 . 在我的情况下,我基于类切换禁用滚动 . 当容器's height is smaller than that of the viewport would stretch the container, which wouldn' t成为您想要的时候设置 .someContainer {height: 100%; overflow: hidden;} . 为此设置 max-height 帐户,但如果内容更改时容器's height is greater than the viewport' s仍然禁用滚动 .
10
设置 height 和 overflow :
html, body {margin: 0; height: 100%; overflow: hidden}
3 回答
HTML css工作正常,如果body标签也没有什么可以写的
在这种情况下,覆盖应该在身体标签上,它更容易控制,但有时会让人头疼 .
这篇文章很有帮助,但只是想分享一个可以帮助他人的轻微替代方案:
设置
max-height
而不是height
也可以解决问题 . 在我的情况下,我基于类切换禁用滚动 . 当容器's height is smaller than that of the viewport would stretch the container, which wouldn' t成为您想要的时候设置.someContainer {height: 100%; overflow: hidden;}
. 为此设置max-height
帐户,但如果内容更改时容器's height is greater than the viewport' s仍然禁用滚动 .设置
height
和overflow
:http://jsfiddle.net/q99hvawt/