I basically have a page that has a header, some main content, and a footer. I want the footer to be sticked at the bottom and the content should be vertically + horizontally centered. Here is what I have:
body {
margin: 0;
}
#wrapper {
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
padding: 2em 0;
background: cyan;
}
main {
flex-grow: 1;
background: turquoise;
}
main div {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
footer {
padding: 2em 0;
background: violet;
}
<div id="wrapper">
<header></header>
<main>
<div>
This should be centered horizontally and vertically within the turquoise box
</div>
</main>
<footer></footer>
</div>
As you can see, the text inside the main content isn't being vertically centered. For some reason, the main div
isn't taking up the full height of main
even though I gave it a height: 100%;
. Does anyone know what is wrong with this code?