CSS高度不工作,如果身体有最小高度 [英] CSS height not working if body has min-height
问题描述
如果身体指定 min-height
,我不会让我的第一个孩子在身体中达到100%的高度。
I don't get my first child in the body to 100% height, if the body has min-height
specified.
<html>
<head>
<style>
html {
height:100%;
}
body {
min-height:100%;
}
#wrapper {
height:100%;
min-width:1120px; /* 250px each side (content width is 870px) */
max-width:2000px;
background-image:url(bg.png);
background-position:50% 25px;
background-repeat:no-repeat;
background-size:cover;
}
</style>
</head>
<body>
<div id="wrapper">
<!-- web content -->
</div>
</body>
</html>
这样会不将包装器调整到窗口的高度。当我删除 min -
并使用 height
,它会工作。但我必须有内容高度变量...
This does not resize the wrapper to the height of the window. When I remove the min-
and use height
, it'll work. But I have to have the content height variable...
我在SO和google上找到了一些其他的帖子,但他们只是问题,没有解决方案。 / p>
I did find some other posts here on SO and on google, but they have just questions and no solution.
推荐答案
我真的找到了一个解决方案!
I actually found a solution!
/ p>
Now I have:
html, body {
height:100%;
}
因此我的身体不是 code>。我不记得为什么我把它改为
min-height
,但我希望我不会面对我明显面临一段时间之前的问题...
So my body is not min-height
. I don't remember why I changed it to min-height
, but I hope I won't face the issue I obviously faced some time ago...
这篇关于CSS高度不工作,如果身体有最小高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!