Fixed div height + strechy div height = 100% screen height. Is it possible?
5 answers
viewport units
and calc
make it easier.
* {
margin: 0;
padding: 0;
}
.one {
height: 50px; /* demo height */
background: red;
}
.two {
height: calc(100vh - 50px);
background: blue;
}
<div class="one"></div>
<div class="two"></div>
EDIT: Flexbox version
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
flex-direction: column;
}
.one {
height: 50px;
background: red;
}
.two {
background: blue;
flex-grow: 1;
}
<div class="one"></div>
<div class="two"></div>
+3
source to share
Take a look at the fiddle . Hope this helps!
HTML -
<div id="wrapper">
<div id="first"></div>
<div id="second"></div>
</div>
CSS -
html, body {
width:100%;
height:100%;
margin:0;
}
#wrapper {
width:300px;
height:100%;
position:relative;
}
#first {
width:300px;
height:200px;
background-color:#F5DEB3;
}
#second {
position:absolute;
top:200px;
bottom:0;
left:0;
width:300px;
background-color:#9ACD32;
}
+1
source to share