如何使身高真的100% [英] How to make the height REALLY 100%
问题描述
让我改述:我希望这个元素(一个div)占据整个页面,不管你滚动多少。拥有100%大小和100%宽度的父元素不起作用,因为它们的处理方式相同。我开始认为我可能不得不使用JS来获取页面的高度,然后绝对定义它。
只需将 position:fixed 应用于元素即可。
如果这是一个叠加:
#overlay
{
position:fixed;
top:0;
剩下:0;
宽度:100%;
身高:100%;
}
注意:IE6不支持修正
in CSS when you set something's width or height to 100% it really only sets it to 100% of the browser window. Is there any way to make it 100% of the whole page?
Let me rephrase: I want this element (a div) to take up the ENTIRE page, no matter how much you scroll. Having parent elements with 100% size and 100% width doesn't work because they are treated the same way. I'm beginning to think that I might have to use JS to get the height of the page and then absolutely define that.
Simply apply position:fixed to the element. If this is an overlay:
#overlay
{
position: fixed;
top: 0;
left: 0;
width:100%;
height:100%;
}
Note: fixed is not supported by IE6
这篇关于如何使身高真的100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!