margin为负值的规则

元素的margin为负值时有一些特定的规则:

  • A negative margin to the left or top will pull the element in that direction,
    overlapping any elements next to it.
  • A negative right or bottom margin will pull in any adjacent elements so that they
    overlap the element with the negative margin.
  • On a floated element, a negative margin opposite the float direction will decrease
    the float area, causing adjacent elements to overlap the floated element. A negative
    margin in the direction of the float will pull the floated element in that direction.
  • Finally, the behavior of negative margins to the sides is slightly moderated when
    used on a nonfloating element without a defined width. In that case, negative
    margins to the left and right sides both pull the element in that direction. This
    expands the element, potentially overlapping any adjacent elements.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容