yoko
yoko

Reputation: 113

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

Upvotes: 8

Views: 11602

Answers (3)

Nividu Lakshika
Nividu Lakshika

Reputation: 1

This is caused because of parent height is 0. Follow these styles up!

html{
    height: -webkit-fill-available;
} 

body{
    height: 100%;
}

Upvotes: 0

Harry
Harry

Reputation: 11

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.

body {
  height: 100%
}

Upvotes: 0

Korgrue
Korgrue

Reputation: 3478

Just use:

body{
   height:100vh;
}

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

Upvotes: 14

Related Questions