【发布时间】:2019-02-23 08:18:36
【问题描述】:
我有一张带页脚的 bootstrap-4 卡。在页脚内部有一个(固定宽度)输入字段和一个按钮。按钮应扩展为 width:100% - 输入字段的宽度。
https://jsfiddle.net/aq9Laaew/224543/
input {
width:3rem;
}
<div class="card">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">The input field has a fixed width, the button should fill-in the rest of the line.</p>
</div>
<div class="card-footer">
<input type="text" value="1" />
<button>
Rest of width
</button>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">The input field has a fixed width, the button should fill-in the rest of the line.</p>
</div>
<div class="card-footer">
<div class="col-auto">
<input type="text" value="1" />
</div>
<div class="col-12">
<button>
Rest of width
</button>
</div>
</div>
</div>
怎么做?正如您在小提琴中看到的那样,我尝试使用 col-auto,但这会将输入 + 按钮的行分成 2 行。
【问题讨论】:
-
col-12类实际上已经占用了 100% 的宽度(因为在引导程序中默认它是 12col-grid)也许你必须调整这个列或者flex选项在这里很有用(见:getbootstrap.com/docs/4.0/utilities/flex)?
标签: css flexbox bootstrap-4