In the snippet below, the tab__icon has a max-width and a max-height, but apparently its causes the text inside of the tab__label next to it to break, while there's actually plenty of space.
I know it's the presence of both max-width and max-height that's causing this problem, because as soon as you change either max-width to width or max-height to height, the text no longer breaks, and everything works as expected.
What am I doing wrong here?
I also tried adding flex-shrink: 0; to tab__label but that would cause the text to overflow the parent, which is not what I want.
.tab-list {
display: flex;
width: 100%;
border: 2px solid red;
justify-content: space-around;
}
.tab-list__item {
flex-shrink: 0;
}
.tab {
display: flex;
align-items: center;
padding: 10px 20px;
background-color: gray;
}
.tab__icon {
max-width: 12px;
max-height: 12px;
flex-shrink: 0;
margin-right: 5px;
}
<div class="tab-list">
<div class="tab tab-list__item">
<svg class="tab__icon" viewBox="0 0 11.25 15"> <g transform="translate(-3)"> <path d="M9.75,7.5A3.75,3.75,0,1,0,6,3.75,3.75,3.75,0,0,0,9.75,7.5Zm0-6.25a2.5,2.5,0,1,1-2.5,2.5A2.5,2.5,0,0,1,9.75,1.25Z" transform="translate(-1.125)"></path> <path d="M8.625,14A5.631,5.631,0,0,0,3,19.625a.625.625,0,1,0,1.25,0,4.375,4.375,0,1,1,8.75,0,.625.625,0,0,0,1.25,0A5.631,5.631,0,0,0,8.625,14Z" transform="translate(0 -5.25)"></path> </g> </svg>
<span class="tab__label">Some title here</span>
</div>
<div class="tab tab-list__item">
<svg class="tab__icon" viewBox="0 0 11.25 15"> <g transform="translate(-3)"> <path d="M9.75,7.5A3.75,3.75,0,1,0,6,3.75,3.75,3.75,0,0,0,9.75,7.5Zm0-6.25a2.5,2.5,0,1,1-2.5,2.5A2.5,2.5,0,0,1,9.75,1.25Z" transform="translate(-1.125)"></path> <path d="M8.625,14A5.631,5.631,0,0,0,3,19.625a.625.625,0,1,0,1.25,0,4.375,4.375,0,1,1,8.75,0,.625.625,0,0,0,1.25,0A5.631,5.631,0,0,0,8.625,14Z" transform="translate(0 -5.25)"></path> </g> </svg>
<span class="tab__label">Some other title</span>
</div>
</div>
Update: As @TemaniAfif pointed out in the comments, this problem only exists in Chrome, Firefox seems to work as expected.