本文介绍了为什么高度100%不适用于内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此代码中,我有一个粘性页脚和上面的内容部分,但为什么 height:100%
不适用于内容部分?
In this code I have a sticky footer and a content section above, but why height:100%
doesn't work for content section?
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
height: 100%;
}
.content {
background-color: #116655;
height: 100%;
}
.footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 60px;
background-color: #ffcc44;
}
<div class="content">
<div>content</div>
</div>
<footer class="footer">
My footer
</footer>
推荐答案
您需要在 html
html {
position: relative;
height: 100%; /* not min-height */
}
这篇关于为什么高度100%不适用于内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!