I have a layout with two columns - a left div
and a right div
.
The right div
has a grey background-color
, and I need it to expand vertically depending on the height of the user's browser window. Right now, the background-color
ends at the last piece of content in that div
.
I've tried height:100%
, min-height:100%;
etc.
just use "vh" unit instead of "px", which mean view-port height.
Try the following css :
You can use the following CSS to make a div 100% of the height of the browser window:
100vw === 100% of the width of the viewport.
100vh === 100% of the height of the viewport.
If you want to set the
div
width or height 100% of browser-window-size you should usefor width:
100vw
for height:
100vh
or if you want to set it smaller size use css
calc function
. Example:#example { width: calc(100vw - 32px) }
You can use
display: flex
andheight: 100vh
You have to set up only
height:100%
.