<div class="height">
<h2>Make a <code><div></code> 100% Height of Browser Window (Using Flexbox)</h2>
<p>The element with the blue backround stretches to fill its parent no matter the size of the window. This uses flexbox to achieve this effect.</p>
</div>
html, body {
height: 100%;
}
body {
font-family: Arial, sans-serif;
font-size: 20px;
display: flex;
}
.height {
text-align: center;
margin: 0 auto;
max-width: 560px;
background: lightblue;
padding: 0 20px;
flex-grow: 1;
}
p {
text-align: left;
padding: 0 20px;
}
code {
color: firebrick;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.