Css Height In Percent Not Working


Answer :

You need to set a 100% height on all your parent elements, in this case your body and html. This fiddle shows it working.





html, body { height: 100%; width: 100%; margin: 0; }
div { height: 100%; width: 100%; background: #F52887; }

<html><body><div></div></body></html>





Make it 100% of the viewport height:



div {
height: 100vh;
}


Works in all modern browsers and IE>=9, see here for more info.



height: 100% works if you give a fixed size to the parent element.



Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable