Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Height 0 on Body

I always get height: 0 on the body, Why this happens?

Either I use height, min-height, etc.

enter image description here

like image 983
yoko Avatar asked Nov 08 '16 15:11

yoko


People also ask

Why is body height 0 html?

Height = 0 because the parent of the elements have 0 height, so make sure your parent, which is body here have 100% height or else. Save this answer.

Why is my Div height 0?

It has zero height because the content inside it is floated. Floated elements are ignored when calculating the height of their parent. This can be easily solved. Setting its overflow property to "hidden" will force it to wrap around floated elements.

What does body height 100% do?

Conclusion. With no height value provided for the HTML element, setting the height and/or min-height of the body element to 100% results in no height (before you add content).

What does height 100vh mean?

Here, 100vh means that the initial body height will take 100% of the viewport height, whereas the use of min-height instead of height will let the body element grow even more if necessary.


1 Answers

Just use:

body{
   height:100vh;
}

This will force the body to 100% viewport height regardless of the page contents.

like image 173
Korgrue Avatar answered Nov 05 '22 20:11

Korgrue