css margin-left的百分比为什么只是相对于父元素内容的宽度?

对绝对定位元素做水平居中时,伪元素before的margin-left的百分比只是相对于.center内容的宽度,不包含padding的大小;
设置了box-sizing也是无效.

.center {
    left: 50%;
    right: auto;
    position: absolute;
    padding: .425em .25em;
    box-sizing: border-box;
}
.center:before{   
    content: '';
    display: inline-block;
    width: .1px;
    margin-left: -50%;
}
阅读 6k
1 个回答
推荐问题