Reputation: 13367
I want to make the last div
in my body
to fill the remaining space but I'm having some trouble. I have this HTML:
<body>
<div class="content"></div>
<div class="footer"></div>
</body>
and this CSS:
body, html {
height: 100%;
}
.content {
height: 100px;
background-color: red;
}
.footer {
height: 100%;
background-color: #ccc;
}
Here is a JSFiddle.
It's not working because a vertical scrollbar is appearing.
Any idea how I can do this?
Upvotes: 0
Views: 591
Reputation: 35670
You can make it a calculation:
.footer {
height: calc(100% - 100px);
}
Also, add this style:
body,html {
margin: 0px;
}
content
is unknown, you can use a flexbox solution:
body, html {
height: 100%;
width: 100%;
margin: 0px;
display: flex;
flex-direction: column;
}
.footer {
flex: 1;
}
Upvotes: 1