Wednesday, 10 May 2017

Make div 100% height of browser window

How can this be used to make a divider fill the height of the browser?


For this question, we can make use of vh: 1vh is equal to 1% of the viewport's height. That is to say, 100vh is equal to the height of the browser window, regardless of where the element is situated in the DOM tree:

HTML
<html>
<head>
<title>Make div 100% height of browser window <title>
</head>
<div> </div>
<html>

CSS
<style>
div {
    height:100vh;
background:#ddd;
}
</style>