I centered 2 divs
using flex
, and I want to add a third div
to the bottom of the page. Just like the image below
(I don't want the first 2 divs
to move up because the third div
. I want the first 2 divs
to be centered based on its parent.)
I tried doing it, but the third div
gets pushed off screen. And I can't make #centerWrapper's height
less than 100%
, because then the 2 divs
won't be centered on the full page.
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body,
#parent {
width: 100%;
height: 100%;
}
#centerWrapper {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
#centerWrapper * {
width: 100px;
height: 100px;
}
#firstChild {
background-color: brown;
}
#secondChild {
background-color: lightblue;
}
#thirdChild {
background-color: greenyellow;
}
<div id="parent">
<div id="centerWrapper">
<div id="firstChild"></div>
<div id="secondChild"></div>
</div>
<div id="thirdChild"></div>
</div>