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;
}