$(window).height()似乎不正确 [英] $(window).height() doesn't seem exact
问题描述
我有一个div,其高度大于屏幕,并且我试图消除滚动条,并使它仍然充满页面(无论页面大小如何).我先设置overflow: hidden
,然后再设置$(window).height()
,但仍然看到滚动条.
I have a div whose height is larger than the screen and I'm trying to eliminate the scrollbar and have it still fill the page (whatever size the page is). I set overflow: hidden
and then set the $(window).height()
but I'm still seeing a scroll bar.
执行$(window).height() - 20
可以消除它,但看来我不应该这样做.因此- 20
可能在jsfiddle.net窗口中工作...如果窗口更大,该怎么办?
Doing $(window).height() - 20
eliminates it but it doesn't seem like I should have to do that. And so maybe - 20
works in the jsfiddle.net window... what if the window is bigger?
推荐答案
窗口高度未考虑默认情况下应用于正文的页边距.如果消除此余量,您将获得想要的效果:
The window height does not take into account the margin that is by default applied to the body. If you eliminate this margin you should get the effect you want:
html, body {
margin: 0;
padding: 0;
}
这篇关于$(window).height()似乎不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!