我发现Chrome和Firefox/Safari之间的Flexbox实现有所不同。如果您的位置绝对元素没有设置顶部/底部/左侧/右侧,则在Chrome中,元素捕捉到顶部:0,左侧:0,而在其他浏览器中,顶部和左侧值与元素相同静态定位。Flexbox和位置绝对没有顶部/底部在Chome与FF和IE
Take a look at the codepen here.
什么是Flexbox的规范针对这种情况的建议?哪些浏览器或浏览器正在演示buggy行为?
HTML
<div class="flex">
<div class="offset">Offset</div>
<div class="absolute">Absolute</div>
</div>
CSS
.flex {
display: flex;
flex-direction: column;
width: 300px;
background: #eee;
height: 200px;
padding: 8px;
}
.offset {
width: 300px;
height: 96px;
background: #ccc;
margin-bottom: 8px;
}
.absolute {
position: absolute;
background: red;
color: white;
width: 300px;
height: 96px;
}
看看规格,预期的行为由W3C清楚地概述。 – TylerY86
这不是重复的,“justify-content:space-between;”根本不涉及。 – TylerY86
@ TylerY86,阅读它说:**这个问题已经在这里得到了答案:**这不是关于这个问题,而是关于答案。 –