我连续有两列,这两列也包含一行。如果页面宽度达到“ xs”的断点,则左列的行将其列堆叠在一起。
右列的高度大于左列的高度。这导致左列底部有很多空白。
我想让左列在由右列创建的可用空间上展开堆叠的列。
Bootstrap4的类justify-content-between
和css属性justify-content: space-between;
似乎是一个不错的选择,但是我不知道如何在这种情况下使用它们。
帮助将不胜感激,谢谢!
小提琴here
和以下代码段:
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<div class="container">
<div class="row">
<!-- left column -->
<div class="col-6">
<div class="row">
<div class="col-12 col-md-4">column 1</div>
<div class="col-12 col-md-4">column 2</div>
<div class="col-12 col-md-4">column 3</div>
</div>
</div>
<!-- right column -->
<div class="col-6">
<div class="row">
<div class="col-12">
<p>
imagine this col was really tall, and I wish the columns one, two, and three from the left col would justify between themselves to match the overall height of this column
</p>
</div>
</div>
</div>
</div>
</div>
最佳答案
您只需在第一列的h-100
元素中添加row
类-参见下面的演示:
.container > .row > .col-6 > .row > div {
border: 1px solid #ddd; /* border for illustration */
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<div class="container">
<div class="row">
<!-- left column -->
<div class="col-6">
<div class="row h-100"> <!-- <= added h-100 class here -->
<div class="col-12 col-md-4">column 1</div>
<div class="col-12 col-md-4">column 2</div>
<div class="col-12 col-md-4">column 3</div>
</div>
</div>
<!-- right column -->
<div class="col-6">
<div class="row">
<div class="col-12">
<p>
imagine this col was really tall, and I wish the columns one, two, and three from the left col would justify between themselves to match the overall height of this column
</p>
</div>
</div>
</div>
</div>
</div>
关于css - 在折叠的 bootstrap 行上垂直对齐内容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46024592/