jquery - header、container 和 footer 需要包含整个布局而不使用固定位置

标签 jquery html css

有什么方法可以让页眉、容器和页脚需要包含整个布局而不需要在 CSS 中使用固定位置 html fiddle

<div class="wrapper">
  <header>
    <img src="https://www.ecobin.com.au/skin/frontend/ultimo/default/images/footer_grass.jpg" alt="">  
   </header>
  <div class="container">
    <p>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
      survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </p>
    <p>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
      survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </p>
  </div>
  <footer>footer come here</footer>
</div>

CSS:

header img {
  width: 100%;
}

footer {
  height: 40px;
  background: #666;
  color:#fff;
}

最佳答案

类似的东西?

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
#page {
  height: 100%;
}
#header {
  height: 50px;
  background: yellow;
}
#content {
  height: calc(100% - 100px);
  background: grey;
  overflow: auto;
}
#footer {
  height: 50px;
  background: blue;
}
<div id="page">
  <div id="header">Header</div>
  <div id="content">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  </div>
  <div id="footer">Footer</div>
</div>

关于jquery - header、container 和 footer 需要包含整个布局而不使用固定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40153457/

相关文章:

php - 从每个字段的列中获取值,但它返回 NULL?

html - 页脚既固定又不覆盖内容(不使用显式值)

javascript - 滚动时触摸的 CSS 或 Javascript 事件

javascript - 单击浏览器的后退按钮时重定向到特定页面

jquery - 删除悬停时内置的工具提示?

jquery - 将 Flot 与 Bootstrap 3 Modal 结合使用,y 轴未对齐

javascript - jquery 检测显示或可见性的变化

html - 在表 td 的输入内将长行换行成多行

html - 滚动行为平滑, anchor 标记没有区别

html - 根据条件删除 detailPanel 导致填充