答案 0 :(得分:1)
这取决于您的情况,但是通过添加第三个不可见元素,可能会有一些解决方法。
示例HTML:
<div class="parent">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
CSS示例:
.parent {
display: flex;
justify-content: space-between;
}
.left {
width: 100px;
height: 60px;
background: red;
}
.center {
width: 50px;
height: 70px;
background: blue;
}
.right {
width: 70px;
height: 100px;
background: yellow;
visibility: hidden;
}
小提琴:https://jsfiddle.net/eqcndn3m
作为flex的替代方法,您可以使用3个宽度相等的浮动元素,并将最后一个保持为空:
<div class="parent">
<div class="column align-left">
<div class="left"></div>
</div>
<div class="column">
<div class="center"></div>
</div>
<div class="column"></div>
</div>
.parent {
text-align: center;
}
.column {
float: left;
width: 33.33%;
}
.align-left {
text-align: left;
}
.left {
display: inline-block;
width: 100px;
height: 60px;
background: red;
}
.center {
display: inline-block;
width: 50px;
height: 70px;
background: blue;
}