我們在 html 輸出中有一些垂直對齊的文本:
Test 1
Test 2
Test 3
Test 4
現在我們希望這些文本horizontally align使用css:
Test 1 Test 2 Test 3 Test 4
有沒有辦法使用 css 做到這一點?
更新 :
<div class="horizontal">
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
</div>
uj5u.com熱心網友回復:
您還可以使用display: inline-block容器內的所有 div
.horizontal div {
display: inline-block;
}
<div class="horizontal">
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
</div>
uj5u.com熱心網友回復:
僅使用flex:
.container{
display: flex;
gap: 20px;
}
<div class="container">
<div>test1</div>
<div>test2</div>
<div>test3</div>
<div>test4</div>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/444994.html
