提问者:小点点

使正文高度达到浏览器窗口的100%


我有这样的结构:

<body>

    <div id="header">..</div>

    <div id="content">..</div>

    <div id="footer">..</div>

</body>

和此CSS:

正文{color:white;font-family:“play”,无衬线;max-width:2560px;margin:0 auto;min-width:960px;height:100%;padding:0;}

#header {
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    min-width: 960px;
    height: 95px;
    background-image: url("../images/header-bg.png");
}

#content {
    margin: 0 auto;
    position: relative;
    max-width: 1600px;
    height:100%;
    overflow:hidden;
}

#footer {
  background-color: #009EDB;
  background-image: url("../images/footer-bg.png");
  bottom: 0;
  height: 30px;
  margin: 0;
  position: relative;
  width: 100%;

}​

而不是body高度的100%浏览器窗口。我有什么问题?多谢了。

JsFiddle


共2个答案

匿名用户

添加:

html {
    height: 100%;
}

给你的CSS。

请参阅此处的更新-http://jsfidle.net/xktpv/4/

匿名用户

为了让它发挥作用。您必须使父和子都具有100%的高度。

html, body {
    height:100%; /*both html and body*/
}
body {
    margin: 0; /*reset default margin*/
}