I'm trying to get my footer to stick to the bottom of the page using margin-top: auto;
but it doesn't have any effect.
I thought it might be because the parent has no height set but when setting height: 100vh
it just shrinks the footer: https://i.stack.imgur.com/sPuEI.png
I can't figure out why this isn't working.
HTML:
<body>
<div class="footer">
<p>Text here</p>
</div>
</body>
CSS:
body {
display: flex;
flex-direction: column;
flex: 1;
}
.footer {
background-color: #1F2937;
color: white;
display: flex;
align-items: center;
justify-content: center;
height: 100px;
margin-top: auto;
}
I'm working through a project on "The Odin Project". Here's the full code: codepen