0
I wanted to know why the property height in css does not obey the given value in % but obey the given value in px, in % is as if only width works, someone can explain to me why this happens and how to get around this problem using %?
code I was doing, note that on 1° div I set the height greater than the width in px and it obeyed the proportions, but when I used a higher height in % it was ignored.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#vermelho{
background-color: red;
width: 300px;
height:1000px;
}
#amarelo{
background-color: yellow;
width: 50%;
height: 100% ;
}
</style>
</head>
<body>
<div id="vermelho"> </div>
<div id="amarelo">
<p>ewqeqwewqeq </p>
</div>
</body>
</html>
then the body ,by default, does not come with 100% height more yes 100% width?
– Akali
@Akali I think yes, the height of the browser needs the definition of the developer to know how much height it needs. In many cases this is not used, because as you put content inside the <body>, it increases this height, so in the end you do not need to use.
– Sumback