如何让 <div> 始终全屏显示?

新手上路,请多包涵

不管它的内容是怎样的。

是否有可能做到这一点?

原文由 Mask 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 364
1 个回答

这总是对我有用:

 <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
        html, body {
            height: 100%;
            margin: 0;
        }

        #wrapper {
            min-height: 100%;
        }
    </style>
    <!--[if lte IE 6]>
    <style type="text/css">
        #container {
            height: 100%;
        }
    </style>
    <![endif]-->
</head>

<body>
    <div id="wrapper">some content</div>
</body>

这可能是解决此问题的最简单方法。只需要设置四个 CSS 属性(虽然其中一个只是为了让 IE 开心)。

原文由 Adam Harte 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏