I want to position the content of a flex container to be in the center on the cross axis. As far as I know the "align-items" will do that however for "align-items" to work we need to specify the height explicitly. Am I right?
Okay, I specified the height explicitly but on the "header" block-level element which houses the flex-container. The flex container doesn't seem to care about the block container, though. Why does that happen? Is the flex container removed from the normal flow?
:root {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}
.header {
background: orchid;
height: 100px;
}
.flex-container-1 {
display: flex;
align-items: center; /* this doesn't seem to work */
/* unless I specify the height on the
flex container itself */
}
<header class="header">
<div class="flex-container-1">
Flex Container 1
</div>
</header>