WICG / layout-instability

A proposal for a Layout Instability specification
https://wicg.github.io/layout-instability/
Other
158 stars 26 forks source link

Margin Collapsing can cause not-visible shifts to elements #119

Open mmocny opened 1 year ago

mmocny commented 1 year ago

Margin collapsing can sometimes turn a small shift on a child element into a large shift on a parent/sibling element.

For example:

Visually-- only the two colored elements shifted.

But, actually the body element experienced "margin collapsing", which technically meant the whole body shifted down.

(It's not so much that the shift didn't happen, technically it did, but it's not exactly producing the result we would expect. In the example, only the two child elements visually shift.)

Screenshot 2023-03-31 at 12 09 50 PM

However, if you apply e.g. a Border to the body, that disabled margin-collapsing and the (more visually) correct CLS is reported.

Screenshot 2023-03-31 at 12 14 32 PM