1

我想创建一个div适合浏览器视口的完整高度和宽度的。我只是想到了简单的CSS,例如:

#wrapper { width: 100%;
           height: 100%;
           background-color: red;
}

但它不适用于高度。#wrapper没有任何高度。为什么?

提前致谢。

4

2 回答 2

6
#wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: red;
}

http://fiddle.jshell.net/zDuWh/

或者

html, body { height: 100% }

#wrapper {
    width: 100%;
    height: 100%;
    background-color: red;
}

http://fiddle.jshell.net/VJv6h/

于 2013-09-02T19:52:06.563 回答
0

这个怎么样:-

#wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: red;
}

或者

html { height: 100% }
body { height: 100% }
于 2013-09-02T19:52:34.843 回答