我有一個簡單的 div,其中包含一些錨標記和一個按鈕。我希望前三個錨標簽左對齊,按鈕右對齊。但我希望他們都在同一行。我的示例顯示了右側的所有四個元素。我怎樣才能做到這一點?謝謝
請看 我的例子
我只想要頁面左側的前三個按鈕和右側的最后一個按鈕。但是,我想讓它們保持對齊并在同一行。
uj5u.com熱心網友回復:
你可以使用 flexbox,有很多方法,其中之一是:
.extra-buttons {
display: flex;
margin-bottom: 5px;
}
button {
margin-left: auto;
}
另一種(更清潔的)方法是將鏈接包裝在 div 中并在 .extra-buttons 上應用 justify-content: space-between:
HTML:
<div class="extra-buttons">
<!-- How do I align these three anchor tags to the left -->
<div>
<a class="btn">
<span class="glyphicon glyphicon-refresh"></span> Refresh
</a>
<a class="btn">
<span class="glyphicon glyphicon-print"></span> Print
</a>
<a class="btn">
<span class="glyphicon glyphicon-plus"></span> Add
</a>
</div>
<!-- But keep this at the right (end) -->
<button>Reset</button>
</div>
CSS:
.extra-buttons {
display: flex;
justify-content : space-between
margin-bottom: 5px;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/408968.html
標籤:
下一篇:如何將容器div變成內容滑塊
