I am trying to center text next to an inline-block element but using negative margin on the span element changed the layout of the whole content. Can anyone help me with this issue?
Here is my code:
fieldset {
max-width: 350px;
margin: 0 auto;
padding:1px;
display: flex;
justify-content: space-around;
align-items: center;
}
.legend-item-box {
display: inline-block;
height: 16px;
width: 30px;
margin-right: 5px;
margin-left: 0;
border: 1px solid #999;
}
.a {
background:#8DD3C7;
}
.b {
background:#FFFFB3;
}
<fieldset>
<legend>Legend:</legend>
<div class="legend-item-container">
<span class="a legend-item-box"></span>Legend a
</div>
<div>
<span class="b legend-item-box"></span> Legend b
</div>
</fieldset>
Thank you in advance for your help! - Max