Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DIV height set as percentage of screen?

Tags:

html

css

I'm looking to set a parent DIV as 70% of the full 100% screen height. I've set the following CSS but it doesn't seem to do anything:

body { font-family: 'Noto Sans', sans-serif; margin: 0 auto; height: 100%; width: 100%; } .header { height: 70%; } 

For some reason it doesn't seem to be working though and the header isn't 70% of the screen size. Any advice?

like image 303
EdzJohnson Avatar asked Apr 05 '13 20:04

EdzJohnson


People also ask

How do I make my div 100% height?

With the advent of the CSS flex model, solving the 100% height problem becomes very, very easy: use height: 100%; display: flex on the parent, and flex: 1 on the child elements. They'll automatically take up all the available space in their container.

Can height be in percentage in CSS?

The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the value computes to auto .


1 Answers

Try using Viewport Height

div {     height:100vh;  } 

It is already discussed here in detail

like image 150
Salman Avatar answered Nov 10 '22 00:11

Salman