Kevin Powell - CommunityKP-C
Kevin Powell - Community16mo ago
4 replies
Faker

Problem with using percentage as a unit with respect to the min-height property

Hello guys, sorry to disturb you all; can someone explain why my box1 isn't appearing, it's like it doesn't have any height because when I change the height from a percentage to another unit, it works well, but not here

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="styles/test.css" />
    <title>Stacking context</title>
  </head>
  <body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
  </body>
</html>

*, *::after, *::before{
    box-sizing: border-box;
}

body{
    margin: 0;
    min-height: 100svh;
    min-height: 100vh;
}

.box1 {
    width: 10%;
    height: 50%;
    background-color: violet;
}

.box2 {
    width: 200px;
    height: 100px;
    background-color: hsl(240, 66%, 63%);
}

.box3 {
    width: 200px;
    height: 100px;
    background-color: hsl(0, 84%, 66%);
}
Was this page helpful?