【发布时间】:2017-10-10 21:43:25
【问题描述】:
无论我做什么,我似乎都无法让左右浮动的列居中并与其容器的中间对齐。 Flexbox 有没有办法只有左右列,但仍然在中间对齐?它在 Firefox 和 Chrome 上运行良好,但在 Safari 8 上运行良好。
https://jsfiddle.net/vhem8scs/68/
.container {
display: flex;
align-items: center;
justify-content: center;
background: #ccc;
height: 200px;
margin-top: 20px;
}
.column:after {
content: '';
display: table;
clear: both;
}
.column div {
float: left;
}
.column div:last-child {
float: right;
}
更新
我在容器中添加了以下行。
justify-content: space-between
虽然它与容器的中心/中间对齐,但浮动现在不起作用。
【问题讨论】:
-
在您的
.container课程中尝试justify-content: space-between。是这个意思吗? -
@lux 是正确的,谢谢我不得不更新标题,因为我只在 Safari 8 中遇到对齐问题。它在 Chrome 和 Firefox 上运行良好。