سؤال

I have several sections each with margin: 10px; but the vertical margins seem to double up into 20px instead of collapsing into 10px like they should. Any idea why this might be happening?

هل كانت مفيدة؟

المحلول

  • (Larger) margins of a child element may collapse through their container and push the other element further away
  • Margins of floating elements do not collapse
  • Margins of absolutely positioned elements do not collapse

نصائح أخرى

I suggest reading the specification. My guess would be that you have either a border, or some padding that is preventing the collapse.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top