[英]How do I anchor my footer but keep my content height 100%
我正在使用粘性页脚 ,但工作不正常,并且在视口后延伸了200或400像素。
我认为显示我的需求比解释要容易,请参见下文:
编辑:我更新了我的代码以反映它与脚注的外观。
原始代码这是我的代码:
<div id="wrapper">
<header>
Header
</header>
<div id="container">
<div id="content">
Content
</div>
<div id="sidebar">
Sidebar
</div>
</div>
<footer>
Footer
</footer>
</div>
还注意到我在代码中有一个边栏,但在提供的图片中没有。 我还将需要没有背景的侧边栏。
您没有按照本教程进行操作,否则我push
在wrapper
看到一个空的div
其中包含class push
。 同样, footer
不应位于wrapper
。
根据在线教程 ...
<body>
<div class="wrapper">
<header>
Header
</header>
<div id="container">
<div id="content">
Content
</div>
<div id="sidebar">
Sidebar
</div>
</div>
<div class="push"></div>
</div>
<footer>
<p>Copyright (c) 2008</p>
</footer>
</body>
CSS:
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */
}
footer, .push {
height: 142px; /* .push must be the same height as footer */
}
请尝试上面的内容,然后发布您的实际CSS。
尝试使用此方法将页脚固定在底部。
.footer {
width:100%;
position:fixed;
bottom:0;
height:30px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.