Zack Zack - 5 months ago 12
CSS Question

Make div take 100% of browser window height

how could I make sure that a div takes 100% of the height on every single screen resolution. Like here: https://medium.com/design-playbooks/designing-the-hiring-process-e0b59f3ee53, or here: http://blogs.wsj.com/briefly/2015/01/23/greece-austerity-relief-or-exit-the-short-answer/?mod=e2fb

Answer

If you want to achieve a 100 view height (device height) styling on a div or other elements you can use something like this:

.full-height {
  height: 100vh;
}
.full-width {
  width: 100vw;
}
div {
  background: green;
}
<div class="full-height full-width"></div>

This sets the element size using viewport units, where 1 vh is 1% of the viewport's height and 1 vw is 1% of the viewport's width. You can also see an example here: http://adtime.at/projects/github/bearded-cyril/ you can see there that I used this to assign 100vh to the aside on the left left side.

Maybe this is relevant for you: http://caniuse.com/#search=vh

Comments