【发布时间】:2018-11-21 22:30:48
【问题描述】:
我必须创建一个如下所示的布局:
我准备了如下代码:
.red {
width: 50px;
height: 50px;
background-color: red;
margin-right: 20px;
}
.yellow {
width: 50px;
height: 50px;
background-color: yellow;
}
.blue {
width: 50px;
height: 50px;
background-color: blue;
justify-self: end;
}
.wrapper {
display: flex;
background-color: green;
width: 100%;
}
<div class="wrapper">
<div class="red"> </div>
<div class="yellow"> </div>
<div class="blue"> </div>
</div>
但是这个蓝色的 div 不想与右侧对齐:
您可以在这里预览一下: https://jsfiddle.net/ncszob80/17/
我知道我可以用 margin-left: auto 蓝色 div 的 css 样式修复它。
但我想知道是否有可能仅通过使用 flex 功能来创建这样的布局。
所以:
我们只能使用弹性功能
红色 div 和黄色 div 之间需要有一定的间距
蓝色 div 需要在最右边
如何实现?
【问题讨论】: