如果 body 有 min-height,CSS 高度不起作用 [英] CSS height not working if body has min-height

查看:45
本文介绍了如果 body 有 min-height,CSS 高度不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果身体指定了 min-height,我不会让我的第一个孩子达到 100% 的高度.

<头><风格>html {高度:100%;}身体 {最小高度:100%;}#包装{高度:100%;最小宽度:1120px;/* 每边 250 像素(内容宽度为 870 像素)*/最大宽度:2000 像素;背景图片:网址(bg.png);背景位置:50% 25px;背景重复:不重复;背景尺寸:封面;}</风格><身体><div id="包装器"><!-- 网页内容-->

不会将包装器的大小调整为窗口的高度.当我删除 min- 并使用 height 时,它会起作用.但我必须有内容高度变量...

我确实在 SO 和 google 上找到了一些其他帖子,但他们只有问题,没有解决方案.

解决方案

我真的找到了解决方案!

现在我有:

html, body {高度:100%;}

所以我的身体不是min-height.我不记得我为什么把它改成min-height,但我希望我不会遇到我前段时间明显遇到的问题......

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>

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...

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!

Now I have:

html, body {
    height:100%;
}

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...

这篇关于如果 body 有 min-height,CSS 高度不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆