YoungZeeZee
Coder
Hi All,
I have just bumped into this case while i am doing a freecodecamp challenge.
In the freecodecamp editor the div showed per given % but when i tried to do the same in VSC i did not get the same result, so i created a little example.
Could you please tell me how it works as it works with px and vw/vh, rem etc.. but does not with %. and why?I also tried display: block as I saw that on a different forum but it does not works in this case.
Thank you in advance for your help.
I have just bumped into this case while i am doing a freecodecamp challenge.
In the freecodecamp editor the div showed per given % but when i tried to do the same in VSC i did not get the same result, so i created a little example.
Could you please tell me how it works as it works with px and vw/vh, rem etc.. but does not with %. and why?I also tried display: block as I saw that on a different forum but it does not works in this case.
Thank you in advance for your help.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/divs.css">
<title>Divs</title>
</head>
<body>
<div class="div1">
</div>
<div class="div2"></div>
</body>
</html>
CSS:
body {
background-color: green;
}
.div1 {
display: block;
width: 100%;
height: 60%;
/* width: 100rem;
height: 60rem;
width: 100vw;
height: 60vh; */
background-color: black;
color: aqua;
}
.div2 {
width: 10px;
height: 50px;
background-color: aqua;
}