I have a toolbar and I want to place my span element as center of my flex display of the toolbar. I am missing something.
CSS
.toolbar {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 60px;
display: flex;
align-items: center;
background-color: #1976d2;
color: white;
font-weight: 600;
} n
.toolbar img {
margin: 0 16px;
}
.toolbar span {
justify-content: center;
}
HTML
<div class="toolbar" role="banner">
<span>Recipe Book</span>
</div>
I got a solution like this. But I like to understand about justify-content : center
for display flex.
HTML
<div class="toolbar" role="banner">
<div class="spacer"></div>
<span>Recipe Book</span>
<div class="spacer"></div>
</div>
CSS :
.spacer {
flex: 1;
}