I am using flexbox and trying to get six divs to take up the remaining height of the page. Two issues I am having:
- I am having trouble getting the six divs to take up the remainder of the height, but no more.
- I am getting a white margin at the top of the page
My code looks like this:
<!DOCTYPE html>
<html>
<style>
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
h2 {
text-align: center;
}
#all {
background-color: red;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
#main {
display: flex;
width: 80%;
margin: 10px auto;
height: 100%;
}
.category {
border: solid black 2px;
flex: 1;
flex-grow: 1;
margin: 0px 20px;
height: 100%;
text-align: center;
font-size: 1.2em;
font-weight: bold;
}
</style>
<div id="all">
<h2>My page</h2>
<div id="main">
<div class="category">Category 1</div>
<div class="category">Category 2</div>
<div class="category">Category 3</div>
<div class="category">Category 4</div>
<div class="category">Category 5</div>
<div class="category">Category 6</div>
</div>
</div>
</html>
I have tried using various styles such as flex-grow, stretch, and height of 100% to the body. However, none of these seem to be doing the trick. What am I doing wrong?