+ 1
Height px Vs %
When I assign div a height percentage It does not inherit it But when I give it in pixels it inherits Why https://code.sololearn.com/W7l3Jv2W0n3g/?ref=app
3 odpowiedzi
+ 3
The % is a relative value to something. For example the div belongs to body, as in your code, then for the body will be needed an absolute value looks like follows:
body {
background:blue;
height: 100vh;
}
div{
background:yellow;
height: 50%;
//height: 150px;
}
+ 2
Nice bro it's working
+ 1
body{
background:blue;
height : 100%;
}
div{
background:yellow;
height:50%;
// height : 150px;
}
First i try this use % instead of vh
But i understand it now