margin collapsing
Margin collapsing only occurs with top and bottom margins, left and right margins donโt collapse.
margin
ๆๅ้่ฆ็็นๆง๏ผๅซๅใ้่ท้็ใ(margin collapsing)๏ผๆๆๆฏๅ
ฉๅๆๅคๅๅ
็ด (็ถๅญใๅ
ๅผ) ็ใๅ็ด้่ทใๆ่ชๅ็ตๅๆๅฎๅ้่ทใ้็้่ทๆก็จๆๅคง็ margin ๅผ๏ผๆญคๅคๅฆๆๅ
็ด ๆฌ่บซ้ซๅบฆ็บ 0 ๆ auto๏ผๅๆ็ผ็ไธไธ margin ้็็ๆณใ ๐ Margin Collapsing
preventing margins from collapsing
the margins of flexbox items donโt collapse.
if you add top and bottom padding/border to the parent container, the margins inside it wonโt collapse to the outside.
applying overflow: auto (or any value other than visible) to the container prevents margins inside the container from collapsing with those outside the container.
elements with display: table-cell donโt have a margin, so they wonโt collapse, this also applies to table-row and most other table display types. (exceptions: table, table-inline, and table-caption)
margins between elements
ๅ่
Last updated
Was this helpful?