有什么方法可以让页眉、容器和页脚需要包含整个布局而不需要在 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/