Make div fill the remaining height of the browser window without javascript
3 answers
Compatible in all browsers
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.head {
height: 100px;
top: 0;
width: 100%;
background: #00963F;
position: absolute;
border-width: 5px 5px 0 5px;
border-style: solid;
border-color: white;
color: white;
text-align: center;
}
.cont {
position: absolute;
top: 100px;
width: 100%;
bottom: 0px;
background: #27338B;
border-width: 5px;
border-style: solid;
border-color: white;
color: white;
text-align: center;
}
<div class="head">Fixed height</div>
<div class="cont">Rest of the browser height</div>
+2
source to share
You can use the function for this calc()
.
html, body {
height: 100%;
margin: 0;
}
#top {
background: #00A743;
height: 100px;
}
#bottom {
background: #40008B;
height: calc(100% - 100px);
}
<div id="top"></div>
<div id="bottom"></div>
+3
source to share