html - 展开页面集html和css

标签 html css

我正在构建一个新的博客,它在内容 div 中有一个评论部分。目前,我已经为正文、页眉、导航、内容和页脚设置了我的 css,如下所示。

内容 div 将根据所写评论的数量进行扩展。如何设置内容 div 的 css/html,以便当更多评论(例如:- 200)时,页面将自动扩展。现在我已经将高度和宽度设置为 100%

html, body {
    height: 100%;
    width: 100%;

}

#header {
    background-color:red;
    height:10%;
    margin-bottom:1%;
}
#naigator {
    background-color:red;
    height:5%;
    margin-bottom:1%;
}

#content {
    background-color:red;
    height:75%;
    margin-bottom:1%;
}

#footer {
    background-color:red;
    height:10%
}

最佳答案

改变content的高度样式为min-height:

function addContent() {
  var content= document.getElementById('content');
  content.innerHTML = content.innerHTML+'testing … ';
  if(content.innerHTML.length < 5000) {
    setTimeout(addContent,10);
  }
}
html, body {
  height: 100%;
  width: 100%;
  margin: 0px;
  padding: 0px;
}

#header {
  background-color:#fed;
  height:9%;
  margin-bottom:1%;
}

#navigator {
  background-color:#def;
  height:4%;
  margin-bottom:1%;
}

#content {
  background-color:yellow;
  min-height:74%;
  margin-bottom:1%;
  font: 20pt verdana;
}

#footer {
  background-color:#fed;
  height:10%;
}
<div id="header">
  <button onclick="addContent()">Add Content</button>
</div>
<div id="navigator"></div>
<div id="content"></div>
<div id="footer">Footer</div>

关于html - 展开页面集html和css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27415341/

相关文章:

html - 导航栏无法正常工作

javascript - 如何在单击 jQuery 时将 +200 毫秒添加到 css 动画持续时间

JQuery 隐藏元素和子元素

html - 拉伸(stretch) Div 内容

html - 带有评论框的文本溢出

css - 可以根据嵌套级别更改背景颜色吗?

html - 我想使用 bootstrap 和 css3 设计一个表单

jquery - Jquery 表中的 sibling

html - 容器未拉伸(stretch)至页面宽度

java - JSF Trinidad SelectBooleanCheckbox 不带标签