如果您需要底部 50 像素,只需将容器向上拖动 50 像素并使用负边距,并给它 100% 的高度。像这样的东西应该有效:
<!DOCTYPE html>
<html>
<head>
<title>100% minus 50px</title>
<style type="text/css">
html, body {
height: 100%;
}
body {
background: #000;
margin: 0;
}
#almost100 {
padding-top: 50px;
height: 100%;
}
#container {
background: #f08;
min-height: 100%;
margin-top: -50px;
}
p {
margin: 0;
}
#footer {
background: #f00;
height: 50px;
}
</style>
</head>
<body>
<div id="container">
<div id="almost100">
<p>:)</p>
</div>
</div>
<div id="footer">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5056 次 |
| 最近记录: |