前端外邊距(margin)的問題

1.上下外邊距會疊壓

2.父子級包含的時候,子級的margin-top會傳遞給父級。

3.設置  margin-left:auto 時,此時 元素會緊緊的靠在 右側

4.設置  margin-right:auto 時,此時 元素會緊緊的靠在 左側

5.綜合3.4兩點  當同時設置   margin-left:auto; margin-right:auto 時,元素會緊緊的位於父類元素的正中間 


總結:

     外邊距存在很多問題,建議用內邊距(padding)替代外邊距

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章