Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mmocny opened this issue Mar 31, 2023 · 0 comments
Open

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

mmocny opened this issue Mar 31, 2023 · 0 comments

Comments

@mmocny
Copy link

mmocny commented Mar 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant