【发布时间】:2023-03-20 01:35:02
【问题描述】:
我发现 Chrome 和 Firefox/Safari 在 flexbox 实现方面存在差异。当您有一个没有设置 top/bottom/left/right 的绝对位置元素时,在 Chrome 中该元素将对齐到 top: 0, left: 0,而在其他浏览器中,top 和 left 值与元素相同是静态定位的。
Take a look at the codepen here.
对于这种情况,flexbox 规范的建议是什么?哪些浏览器或哪些浏览器出现错误行为?
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 清楚地概述了预期的行为。
-
这不是重复的,
justify-content: space-between;根本不涉及。 -
@TylerY86,阅读它的内容:这个问题在这里已经有了答案:这不是关于问题,而是关于答案。
-
我阅读了答案。我看不出
justify-content: space-between和这个有什么关系,或者position: absolute和另一个有什么关系。 -
您的回答没有说明 W3C 规范。嗯,随便。
标签: html css google-chrome safari flexbox