Bootstrap 4 列的弹性对齐
Bootstrap 4 flex alignment of columns
我完全糊涂了。我弄清楚了这一点,然后刷新了 jsfiddle,解决方案以某种方式发生了变化。我有一排两列。我无法让两列在同一行上对齐。我尝试使用 justify-content-around
但它不起作用。帮助将不胜感激。
<div class="container-fluid">
<div class="d-flex flex-row justify-content-around my-flex-container">
<div class="d-flex flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1</div>
<div class="flex-row my-flex-container">Row 2</div>
<div class="flex-row my-flex-container">Row 3</div>
<div class="flex-row my-flex-container">Row 4</div>
</div>
<div class="d-flex flex-column my-flex-container-column">
<div class="d-flex flex-row my-flex-container">
<div class="flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1
</div>
<div class="flex-row my-flex-container">Row 2
</div>
</div>
</div>
<div class="d-flex flex-row flex-1 my-flex-container">
<div class="my-auto">ROW 3</div>
</div>
</div>
</div>
</div>
您需要将您的 Bootstrap 版本从 Alpha 版本更新到 Beta 版本,您可以获得它 here。
.my-flex-container {
border: 2px solid green;
}
.my-flex-container-column {
border: 2px solid green;
}
.flex-1{
flex: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="d-flex flex-row justify-content-around my-flex-container">
<div class="d-flex flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1</div>
<div class="flex-row my-flex-container">Row 2</div>
<div class="flex-row my-flex-container">Row 3</div>
<div class="flex-row my-flex-container">Row 4</div>
</div>
<div class="d-flex flex-column my-flex-container-column">
<div class="d-flex flex-row my-flex-container">
<div class="flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1
</div>
<div class="flex-row my-flex-container">Row 2
</div>
</div>
</div>
<div class="d-flex flex-row flex-1 my-flex-container">
<div class="my-auto">ROW 3</div>
</div>
</div>
</div>
</div>
我完全糊涂了。我弄清楚了这一点,然后刷新了 jsfiddle,解决方案以某种方式发生了变化。我有一排两列。我无法让两列在同一行上对齐。我尝试使用 justify-content-around
但它不起作用。帮助将不胜感激。
<div class="container-fluid">
<div class="d-flex flex-row justify-content-around my-flex-container">
<div class="d-flex flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1</div>
<div class="flex-row my-flex-container">Row 2</div>
<div class="flex-row my-flex-container">Row 3</div>
<div class="flex-row my-flex-container">Row 4</div>
</div>
<div class="d-flex flex-column my-flex-container-column">
<div class="d-flex flex-row my-flex-container">
<div class="flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1
</div>
<div class="flex-row my-flex-container">Row 2
</div>
</div>
</div>
<div class="d-flex flex-row flex-1 my-flex-container">
<div class="my-auto">ROW 3</div>
</div>
</div>
</div>
</div>
您需要将您的 Bootstrap 版本从 Alpha 版本更新到 Beta 版本,您可以获得它 here。
.my-flex-container {
border: 2px solid green;
}
.my-flex-container-column {
border: 2px solid green;
}
.flex-1{
flex: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="d-flex flex-row justify-content-around my-flex-container">
<div class="d-flex flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1</div>
<div class="flex-row my-flex-container">Row 2</div>
<div class="flex-row my-flex-container">Row 3</div>
<div class="flex-row my-flex-container">Row 4</div>
</div>
<div class="d-flex flex-column my-flex-container-column">
<div class="d-flex flex-row my-flex-container">
<div class="flex-column my-flex-container-column">
<div class="flex-row my-flex-container">Row 1
</div>
<div class="flex-row my-flex-container">Row 2
</div>
</div>
</div>
<div class="d-flex flex-row flex-1 my-flex-container">
<div class="my-auto">ROW 3</div>
</div>
</div>
</div>
</div>