When I inspect the codes below, I noticed the body tag can’t stretch full height according to HTML height due to that the scroll appears, and I don’t want that.
I try set display to flex column and that work perfect, no scroll and that size as my expected. But I can’t understand why it’s work when I set display to flex column.
HTML
<!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="./style.css">
<title>Float Property</title>
</head>
<body>
<main>
<section class="header"></section>
<section class="body">
<aside></aside>
<article></article>
</section>
<section class="footer"></section>
</main>
</body>
</html>
CSS
* {
padding: 0;
margin: 0;
}
body {
width: 100%;
height: 100vh;
background-color: white;
}
main {
width: 100%;
height: 100vh;
> .header {
height: 15%;
background: gray;
margin: 1rem;
}
> .body {
height: 70%;
margin: 1rem;
display: flex;
> aside {
width: 30%;
height: 100%;
background: gold;
}
> article {
width: 70%;
height: 100%;
background: gray;
margin-left: 1rem;
}
}
> .footer {
height: 15%;
background: gray;
margin: 1rem;
}
}