W3C home > Mailing lists > Public > public-css-archive@w3.org > April 2018

[csswg-drafts] [css-grid-2] subgrid border/padding/margin

From: Mats Palmgren via GitHub <sysbot+gh@w3.org>
Date: Tue, 17 Apr 2018 17:47:50 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-315164807-1523987269-sysbot+gh@w3.org>
MatsPalmgren has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-grid-2] subgrid border/padding/margin ==
There's a problem with how subgrid BPMs (border/padding/margin) are supposed to work.  As I understand [the spec](https://drafts.csswg.org/css-grid-2/#subgrid-items), the subgrid item itself doesn't participate in the TSA (track sizing algorithm) of its parent grid in a subgridded axis.  Instead, the size contributions of any items in edge tracks are inflated with the BPM on that side.  This doesn't work very well when there are no items, or only subgrid items, or items only in non-edge tracks.  In those cases, the BPM isn't accounted for and the parent track size will be too small causing the subgrid to overflow it.

I suggest we fix this by making subgrids contribute its BPM as a span=1 contribution to the TSA in the relevant edge track(s).  So, for example 3x3 subgrid with `border:10px solid` will contribute 10px to its start and end tracks.  The 10px size is fed into the TSA the same way as a span=1 item would.  Any items in those tracks should also be inflated by 10px, same as before.  If the subgrid is 1x1 instead, then it contributes 20px.  This should make the parent large enough to fit the subgrid.  I've implemented this in my prototype subgrid implementation in Gecko and it seems to work well.  (It was trivial to implement.)

ISSUE 1: I propose we add subgrid BPM contributions per above

Size contributions involving BPM's also needs to be floored at zero at some point and the spec needs to specify when that occurs.  I tend to think the flooring occurs as late as possible, just before the size is fed into the TSA, so for example, an empty span=1 subgrid with `margin-top:-20px; margin-bottom:30px` contributes 10px.  If the subgrid's span > 1 then it contributes 0px to its start track and 30px to its end track.  When applying the relevant BPMs to the size of an item they are simply added as is and the final result is then floored at zero.  E.g. an item with `height:10px` in the 1x1 case would contribute 20px.  In the 3x3 case, a 10px item (w. span=1) in the first track contributes zero; in the last track it would contribute 40px; with span=3 it would contribute 10px.  BPMs of nested subgrids are also accumulated as is without flooring and only the final result is floored.

ISSUE 2: specify that size contributions are floored at zero and that the flooring occurs after all lengths are summed up just before the final result is fed into the TSA

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2592 using your GitHub account
Received on Tuesday, 17 April 2018 17:47:57 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:28 UTC