I use flexbox to create a sticky footer.
body {
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
}
header, footer {
background-color: #c9c9c9;
padding: 20px;
}
main {
flex: 1;
margin: 0 auto;
max-width: 300px;
border: 1px solid red;
}
<header></header>
<main>This is some content</main>
<footer></footer>
Run codeHide resultJsfiddle
This works fine, but the width is <main>now minimized to fit the content, rather than expanding to the maximum width. This only happens when the auto field is set.
Is there a way to make it <main>expand to its maximum width when automatic margins are set?
source
share