一只名叫tom的貓
2023-04-01 15:42:55
我試圖讓幾個按鈕垂直拉伸到容器的大小,但我不知道我以前是怎么做到的。我已經(jīng)在https://getbootstrap.com/docs/4.0/utilities/flex/上嘗試了所有的可能性(比如 align-items-stretch、align-self-stretch、align-content-stretch,但似乎都沒有單列垂直拉伸的任何東西,至少我是如何實(shí)現(xiàn)它們的。它是怎么做到的?謝謝!(https://codepen.io/jasonws/pen/poyYMpz)<div class="container mt-3"> <div class="d-flex align-content-stretch border" style="height:150px; width:200px; flex-direction: column"> <button type="button" class="btn btn-primary my-1">Flex item 1</button> <button type="button" class="btn btn-primary my-1">Flex item 2</button> <button type="button" class="btn btn-primary my-1">Flex item 3</button> </div></div>
1 回答

MYYA
TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個贊
只需從 d-flex 類中刪除其他內(nèi)容
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container mt-3">
<div class="border" style="display: grid">
<button type="button" class="btn btn-primary my-1 m-2">Flex item 1</button>
<button type="button" class="btn btn-primary my-1 m-2 ">Flex item 2</button>
<button type="button" class="btn btn-primary my-1 m-2 ">Flex item 3</button>
</div>
</div>
添加回答
舉報
0/150
提交
取消