A combination of position: absolute
and left: 0
on the .icon
would do the trick.
.container {
display: flex;
justify-content: space-around;
background-color: #7D8F99;
width: 100%;
height: 50px;
position: relative;
}
.title {
background-color: #9AADB8;
}
.icon {
background-color: #1AADA9;
position: absolute;
left: 0;
}
<div class="container">
<span class="icon">icon</span>
<span class="title">text</span>
</div>
Or, if you wanted to use only flex, you could add an empty spacer element on the right side. The spacer element would need to have the same width as the .icon
element. And honestly, adding an empty element for the sake of layout isn't a great option. So I'd recommend the first method.
.container {
display: flex;
justify-content: space-between;
background-color: #7D8F99;
width: 100%;
height: 50px;
}
.title {
background-color: #9AADB8;
}
.icon {
background-color: #1AADA9;
width: 30px;
}
.spacer {
/* width must match icon width */
width: 30px;
}
<div class="container">
<span class="icon">icon</span>
<span class="title">text</span>
<span class="spacer"></span>
</div>