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>
答案 0 :(得分:1)
You need to set an actual height on the html
html {
position: relative;
height: 100%; /* not min-height */
}
答案 1 :(得分:0)
Use position: absolute
on the content as well, then use top: 0
and bottom: 60px
this will make the content take up the remaining space. then use overflow: auto;
to allow scrolling the content;
(Demo)
.content {
position: absolute;
top: 0;
bottom: 60px;
background-color: red;
overflow: auto;
}