Re: [css-grid] How to resolve lines for absolutely positioned grid items

On 05/09/2015 01:11 AM, fantasai wrote:
 > On 03/24/2015 11:58 AM, Mats Palmgren wrote:
 >> Q3. what is the start and end lines for "grid-column: 99 / 100"
 >>      in a 3x3 grid?
 >> [... snip ...]
 >> And what is the answer to Q3 if the grid has no tracks at all?
 >> (same as "auto / auto" ?)
 >
 > Tab suggests that we force the explicit grid to always have
 > at least one grid line. The example above would then end up
 > in a zero-width track in a mostly-empty grid of zero-width
 > tracks.
 >
 > Let us know what you think.

Sorry for the late reply.  I just saw that this was added to the spec:
"If these properties don't define any explicit tracks, the explicit
grid still contains one grid line in each axis."
https://drafts.csswg.org/css-grid/#grid-definition
https://github.com/w3c/csswg-drafts/commit/18fddb003b3486b1cbcce184282cb7e41dd18174

That sentence is problematic for several reasons:

1. If a line 1 is always present and explicit then the start column
    resolves to line 2 in the following example:

<div style="display:grid; grid-auto-columns:50px">
<span style="grid-column:A">A</span>
</div>

Which doesn't really make sense to me (I think it should start at
line 1 and it should be an implicit line).  If you really want it
at line 2, what would the rendering be? Is "A" indented 50px or
not?  Is there a track between line 1 and 2?

fantasai's answer above seems to suggest there is, not only an
always present explicit line 1, but also an associated zero-width
track?  The spec doesn't say anything about that though.

2. The alignment subjects for align-/justify-content are the tracks.
    Since there are no tracks in this case, line 1 is always at the
    content start edge and alignment has no effect on it.  This is
    confusing since if "grid-column:1" always matches a line for
    a grid-aligned abs.pos. box then it seems it should be always
    affected by alignment too.

<div style="display:grid; position:relative; justify-content:center">
<span style="position:absolute; grid-column:1">B</span>
</div>

3. Thus far the model has been that lines exist on each side of
    a track, and conversely that all numbered lines have a track
    in-between them.  No tracks <=> no lines.  The added sentence
    breaks that mental model.

As I suggested in my original mail above, I think all lines for
grid-aligned abs.pos. descendants should snap to the padding edge
when the grid has no tracks.  Then there is no need for the added
sentence and all the problems above disappears.

FWIW, the Grid implementation in Gecko rests on the invariant in
point 3 above.  It would be rather complicated for us to support
an explicit line without an associated track.  (A zero-width
track would solve that, but that doesn't seem to play well with
track distribution.)

BTW, the other issues I raised were discussed here:
https://lists.w3.org/Archives/Public/www-style/2015May/0280.html
but I don't see that this added sentence was actually discussed
there.

Regards,
Mats

Received on Thursday, 8 October 2015 18:41:05 UTC