我試圖讓我的兩個按鈕出現在一段文本的最右側。我希望文本和兩個按鈕都相互行內,但文本在左側,兩個按鈕在右側。我已經看到了多種解決方案,我可以只用 1 個按鈕讓它作業,但是當我有兩個按鈕時它不起作用。
我在“弱點”上運行一個 for 回圈并列印出每個弱點。每個弱點都有一個更新和洗掉操作。
我試圖做 margin-left 但每個弱點的長度都不一樣,所以我的按鈕不會排列
我也嘗試使用這篇文章中的一些解決方案,但似乎無法獲得預期的結果:將按鈕右對齊
任何幫助,將不勝感激
HTML
<div *ngFor="let weakness of weaknesses | async">
<div class="flex-box">
<p>{{ weakness }}</p>
<a class="btn btn-light btn-sm pull-right" href="#">Update</a>
<button type="button" class="btn btn-danger btn-sm">Delete</button>
</div>
</div>
uj5u.com熱心網友回復:
嘗試這個:
#btnHolder {
position:fixed;
top:10px;
right:10px;
}
<p>Text is here</p>
<div id="btnHolder">
<button>Update</button>
<button>Delete</button>
</div>
我不知道為什么這么難。它應該更容易。
uj5u.com熱心網友回復:
一種解決方案是使用 flex 自動邊距
nav {
display: flex;
align-items: center;
}
nav button:first-of-type {
/* Key here is margin-left needs to be auto */
margin: 0 10px 0 auto
}
<nav>
<span>Text</span>
<button>Button 1</button>
<button>Button 2</button>
</nav>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/364586.html
