Currently experimenting with the flexbox sticky footer technique to create a dynamic-height footer, which has been a challenge for me. However, I'm facing an issue where the main section does not expand to fill the entire height of the window even after applying 'min-height: 100vh' and 'flex-direction: column' to the body container.
As a result, the footer remains halfway up the page, and I'm unsure why this setup isn't functioning properly despite my research on the topic.
HTML:
<body>
<div id="wrapper">
<main>
<div id="pageContent">
<h1>Page Content</h1>
<h2>Page Content</h2>
<h3>Page Content</h3>
<h4>Page Content</h4>
</div>
</main>
<footer>
<row>
<p>Footer Content</p>
<p>Footer Content</p>
<p>Footer Content</p>
<p>Footer Content</p>
</row>
</footer>
</div>
</body>
CSS:
html, body
{
margin: 0;
padding: 0;
max-width: 100%;
background: #1a1a1a;
}
body
{
display: flex;
min-height: 100vh;
flex-direction: column;
}
main
{
width: 100%;
margin: 0;
padding: 50px 10%;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
flex: 1;
}
main > #pageContent
{
height: 100%;
width: 100%;
margin: 0;
}
footer
{
height: auto;
background: #0d0d0d;
padding: 0 10%;
margin: 0;
}
footer > row
{
display: flex;
}
footer > row > p
{
flex-grow: 1;
flex-basis: 0;
text-align: center;
padding: 25px 0;
margin: 0;
}