Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an element fill the remaining viewport height?

I'd like to use CSS Grid. Something like this I think…

html {
  height: 100%;
}

body {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto [whatever's left of the vh] auto auto;
  position: relative;
}

enter image description here

like image 657
Ben Dunkle Avatar asked Apr 26 '18 13:04

Ben Dunkle


1 Answers

Set the viewport with display: flex and height: 100vh and add to the last element flex-grow: 1

Here is a small fiddle :

https://jsfiddle.net/omA123/y4j9nhpy/

like image 180
oma Avatar answered Sep 18 '22 06:09

oma