Well consider I have two elements: an svg image (icon) and a paragraph (styled to be inline). I wish to render them side to side inside a div, and I wish to align them "in the middle".
Now I "got" this working using display: inline-flex
for the outer div as follow:
<div class="grouper borderhelper">
<p style="display:inline">test</p>
<svg class="icon" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation"><path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"></path><path fill="none" d="M0 0h24v24H0z"></path></svg>
</div>
css:
.grouper {
display: inline-flex;
vertical-align: middle;
align-items: center;
width: 100%;
}
.borderhelper {
border-style: solid;
border-width: 1px;
border-color: 0;
}
.icon {
width: 1em;
height: 1em;
display: inline-block;
font-size: 24px;
}
p {
margin: 0px;
}
However I am wondering: why would I need a flexbox in this case? It makes no sense as there's no flexing to happen, only aligning. Yet when I try to change display to "inline-block" the alignment fails.