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

Interop issue with percentage margins/paddings on grid items #7

Closed
mrego opened this issue Aug 2, 2017 · 2 comments
Closed

Interop issue with percentage margins/paddings on grid items #7

mrego opened this issue Aug 2, 2017 · 2 comments

Comments

@mrego
Copy link
Contributor

mrego commented Aug 2, 2017

This is a well known interop issue that happens in both Flexbox and Grid.
Firefox resolves the percentage margins/padidngs on items against their respective dimension (so different from what happens in regular blocks where they are always resolved against width).
However, Chromium follows the same than blocks.
See Chromium bug #229568.

The spec allows both behaviors: https://drafts.csswg.org/css-grid/#item-margins

Percentage margins and paddings on grid items can be resolved against either:

  • their own axis (left/right percentages resolve against width, top/bottom resolve against height), or,
  • the inline axis (left/right/top/bottom percentages all resolve against width)
    And has a note to avoid use percentage margins/paddings for grid items.

Simple example to reproduce the issue: https://codepen.io/mrego/pen/EvyMNz
In Firefox the top and bottom margins are 10px, while the left and right are 20px.
In Chromium all of them are 20px.

BTW, there are use counters in Chromium to detect the usage of percentage margins/paddings in flex items:

@rachelandrew
Copy link
Owner

On the listing now as #13

Looks like Edge is agreeing with Firefox.

@mikkorantalainen
Copy link

The spec currently says

Percentage margins and paddings on grid items, like those on block boxes, are resolved against the inline size of their containing block, e.g. left/right/top/bottom percentages all resolve against their containing block’s width in horizontal writing modes.

So the expected behavior is now clearly defined.

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

3 participants