我在使用绝对定位与居中的flexbox元素时遇到了问题,在Firefox浏览器中无法正常工作。
这是链接。 HTML
有什么办法可以修复这个问题吗?因为我需要在div中使用绝对定位。
这是链接。 HTML
<div>
<p>Center me!</p>
</div>
CSS
div
{
width:350px;
height:100px;
border:1px solid black;
position:absolute;
left:0;
top:0;
/* Firefox */
display:-moz-box;
display:inline-flex;
-moz-box-pack:center;
-moz-box-align:center;
/* Safari and Chrome */
display:-webkit-box;
-webkit-box-orient:horizontal;
-webkit-box-pack:center;
-webkit-box-align:center;
/* W3C */
display:box;
box-orient:horizontal;
box-pack:center;
box-align:center;
}
有什么办法可以修复这个问题吗?因为我需要在div中使用绝对定位。
position:absolute
会将显示属性从display:-moz-box
更改为display:block
。 - Matt Coughlin