开发者社区 问答 正文

为什么子元素设置{position:relative;left:-50%; }这里的50%是父元素宽度的50%

如题。
不理解为什么父元素设置了
wrap{float:left;position:relative;left:50%}
子元素设置了
innerWrap{position:relative;left:-50%}
子元素是向左偏移了是父元素宽度的50%。

展开
收起
杨冬芳 2016-05-31 18:56:49 1913 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业

    因为规范定义 left的值是百分比时使用包裹元素的宽度
    <percentage> Is a <percentage> of the containing block's width, used as described in the summary

    2019-07-17 19:22:24
    赞同 展开评论
问答地址: