为什么100%不是意味着100%的高度? [英] Why does 100% not mean 100% height?
本文介绍了为什么100%不是意味着100%的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让一些 divs
扩展到填满屏幕,但我很努力。我已分解此jsfiddle 的问题。
I am trying to get some divs
s to expand to fill the screen, but I am struggling. I have broken down the issue on this jsfiddle.
我真正想知道的是为什么 div
,它的100% min-height
What I really want to know is why does the div
, with its 100% min-height
, not expand to that height (or at all) when its parent has the same attribute and does expand?
<body>
<div>
stuff
</div>
</body>
body {
min-height: 100%;
background: red;
}
div {
min-height: 100%;
background: grey;
}
推荐答案
在静态元素上使用100%高度。将position属性从static更改为absolute将为您提供100%的高度。 演示
because you can't really use 100% height on a static element. Changing the position attribute from static to absolute will give you 100% height. demo
发布为答案根据PO的请求。
这篇关于为什么100%不是意味着100%的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文