容器DIV不会超出窗口的原始高度

时间:2011-12-12 23:37:53

标签: css height

我使用以下CSS作为容器DIV,其高度为html,正文设置为100%,但它没有超出this page窗口的边缘,即向上滚动以显示内容在页面下方,容器DIV未显示:

#container {
  padding: 0;
  margin: 0;
  background-color: #292929;
  width: 1200px;
  margin: 0 auto;
  min-height: 100%;
}

有人可以告诉我为什么这不起作用。

2 个答案:

答案 0 :(得分:3)

overflow: hidden添加到:

#container {
    overflow: hidden; /* Right here */
    background-color: #292929;
    margin-bottom: 0;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    min-height: 100%;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
    width: 1200px;
}

这会导致#container流过其中浮动元素的底部,这应该给它计算出的高度。另一个选择是.clearfix

答案 1 :(得分:-2)

您应该使用高度而不是宽度:

height: 1200px;

而不是:

width: 1200px;
相关问题