Flexbox has made setting margin
to auto
a whole lot more powerful. Doing so along the flex axis now takes up any remaining space before dividing it up between the flex items. This is the holy grail of CSS, true vertical centering.
I often use this to push footers down to the bottom of the page when the content is not tall enough. Flex is awesome.
#main {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
background: #B8E986;
}
#menu {
padding: 20px 0px;
font-size: 1em;
background: #D0021B;
width: 100%;
}
#find {
width: 50px;
min-height: 50px;
background: #F5A623;
margin-top: auto;
margin-bottom: auto;
}
<div id="main">
<div id="menu">
Menu div
</div>
<div id="find">
Find div
</div>
</div>