<div class="height">
<h2>Make a <code><div></code> 100% Height of Browser Window (Old Technique)</h2>
<p>The element with the blue backround stretches to fill its parent no matter the size of the window. The key to this is ensuring there is 100% height on the body and html elements, as well as the child element.</p>
</div>
* {
box-sizing: border-box;
}
html, body {
height: 100%;
}
body {
font-family: Arial, sans-serif;
font-size: 20px;
}
.height {
text-align: center;
margin: 0 auto;
max-width: 600px;
background: lightblue;
min-height: 100%;
padding: 0 20px;
}
h2 {
padding-top: 20px;
margin: 0;
}
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.