我知道flexbox爲居中物品提供了一個很好的解決方案。但是當我有3件物品時,我遇到了一個問題,並且我希望中心(第2)物品相對於窗口居中,而與其他2件物品的大小無關。當它的兄弟姐妹擁有不同的寬度時,將一個彈性項目居中
在筆中,您可以看到第二項「客戶端索引」偏離中心,因爲右側的內容大於左側的內容。 我該如何強制它自己居中?
.flex {
display: flex;
align-items: center;
justify-content: space-between;
}
<div class="flex">
<span style="font-size:12px;">small</span>
<span style="font-size:20px;">Client Index</span>
<span style="font-size:18px;">Lots of content that moves the center</span>
</div>