【发布时间】:2018-09-19 15:00:37
【问题描述】:
如果父 div 是相对位置并显示 flex,则 align-items: center,绝对定位的子组件没有按预期居中,而是该组件的顶部居中
有人知道如何解决这个怪癖吗?
https://codepen.io/anon/pen/aYXJZe
.crumb {
width: 100%;
margin-top: 100px;
height: 100px;
background-color: grey;
}
.arrowWrapper {
height: 100px;
width: 100px;
background-color: red;
display: flex;
align-items: center;
position: relative;
}
.arrow {
height: 150px;
width: 80px;
background-color: blue;
position: absolute;
}
<div class="crumb">
<div class="arrowWrapper">
<span class="arrow"></span>
</div>
</div>
【问题讨论】:
-
可以在chrome中打开code pen查看想要的效果
标签: css internet-explorer flexbox internet-explorer-11