I'm trying to build a header component where I want to show an icon in the center of the screen within that header.
My problem is when the right content grows, flexbox shifts everything accordingly and the center content won't get centered anymore, in the given code, the center content of the second container is center within the screen but in the header center
it is not the same.
Basically, I want both the center
content aligned vertically together with the responsiveness. I have tried justify-self: center;
but it's not working...
.container {
display: flex;
align-items: center;
flex-wrap: wrap;
margin-bottom: 8px;
border: 1px solid black;
}
.container>div {
border: 1px solid black;
padding: 8px;
}
.center {
margin-left: auto;
margin-right: auto;
}
<header class="container">
<div class="left">Left Content</div>
<div class="center">Center</div>
<div class="right">Content With Some More Data</div>
</header>
<div class="container">
<div class="center">Center</div>
</div>