I'm attempting to design a layout where the top and center aligned div
s.
https://i.sstatic.net/h2PxG.png
My approach is somewhat successful: https://jsfiddle.net/zeo29uLa/
<div class="flexbox-container">
<div class="top-item">
top
</div>
<div class="center-item">
center
</div>
</div>
<style>
body {
height: 50vh;
}
.top-item {
flex: 1 0 100%;
text-align: center;
align-self: flex-start;
}
.center-item {
align-self: center;
}
.flexbox-container {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
justify-content: center;
height: 100%;
flex-wrap: wrap;
}
</style>
My issue and therefore my question: how can I accurately align the center div in the middle? Currently, there is space above it causing it to align below the desired height.
I have a hunch that resolving this will involve utilizing align-content
correctly within the parent container, but I'm struggling to nail down the solution.