我正在遵循引导程序文档,以使一列比另一列宽。 JSFiddle位于问题的底部。
https://getbootstrap.com/docs/4.3/layout/grid/#setting-one-column-width
当我尝试时:
<div class="row no-lf-margin">
<div class="col-xl-3 col-lg-3 col-md-12 col-sm-12 bg-warning">
1
</div>
<div class="col-xl-7 col-lg-7 col-md-12 col-sm-12 bg-danger">
2
</div>
<div class="col-xl-2 col-lg-2 col-md-12 col-sm-12 bg-secondary">
3
</div>
</div>
但是第一个列(列1,橙色)占用的空间比需要的多,列3(灰色)也占用过多的空间。当我将col-xl-2设置为col1时,占用的空间太小;当我将col-xl-1设置为col3时,占用的空间也太少。就像我需要col1的col-xl-2.5和col3的col-xl-1.5一样。
注意:其他屏幕(md,小屏幕等)工作正常,由于col-md-12和col-sm-12,它们相互叠放。
所以我是根据文档创建的:
<div class="row no-lf-margin">
<div class="col bg-warning">
1
</div>
<div class="col-7 bg-danger">
2
</div>
<div class="col bg-secondary">
3
</div>
</div>
对于col1(橙色)来说结果很好,宽度很好。但是col3(灰色)仍然太大。现在在所有屏幕上,col彼此相邻,而不是在另一个屏幕下方,因为没有col-md-12和col-sm-12:
我尝试创建这两者的混合体:
<div class="row no-lf-margin">
<div class="col col-md-12 col-sm-12 bg-warning">
1
</div>
<div class="col-7 col-md-12 col-sm-12 bg-danger">
2
</div>
<div class="col col-md-12 col-sm-12 bg-secondary">
3
</div>
</div>
但是我到处都是col-12,它们彼此堆叠。
具有版本和目标的JSFiddle:https://jsfiddle.net/gcdn3str/