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.
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容