【发布时间】:2016-05-18 03:12:18
【问题描述】:
https://jsfiddle.net/vhem8scs/
是否可以让两个项目左对齐,一个项目右对齐与 flexbox?链接显示得更清楚。最后一个例子就是我想要实现的。
在 flexbox 中,我有一段代码。使用 float 我有四个代码块。这也是我更喜欢 flexbox 的原因之一。
HTML
<div class="wrap">
<div>One</div>
<div>Two</div>
<div>Three</div>
</div>
<!-- DESIRED RESULT -->
<div class="result">
<div>One</div>
<div>Two</div>
<div>Three</div>
</div>
CSS
.wrap {
display: flex;
background: #ccc;
width: 100%;
justify-content: space-between;
}
.result {
background: #ccc;
margin-top: 20px;
}
.result:after {
content: '';
display: table;
clear: both;
}
.result div {
float: left;
}
.result div:last-child {
float: right;
}
【问题讨论】: