Re: [css-grid] Allow referencing the last line of implicit grids

On Mon, Jul 13, 2015 at 10:09 AM, François REMY
<francois.remy.dev@outlook.com> wrote:
> Hi Patrick,
>
> I’m having a hard time understanding how your usecase would work in an
> efficient way, and react properly in edge cases.
>
> If you want the amount of columns to equate the amount of tabs, you’re
> relying on automatic placement, right? Then you cannot possibly have two
> rows because the items would be allowed to locate on the second row.
>
> Well, I guess your answer to this is that they would do but can’t because
> the second row is already filled with the item you placed there using “1 /
> -1i” (where -1i means the last implicit line). However, you’re forcing a
> relayout each time a new item is placed because by increasing the amount of
> columns, it changes the placement of positioned grid items and therefore
> require a new pass of the positioned-items layout, which will update the
> “busy-cells matrix”. Optimizations may be made but could be hard to
> implement.

Not really, no.  Especially if we limited it to only specifying the
*last* implicit line (rather than letting you offset arbitrarily from
that), then it's easy - the presence of such a grid item implicitly
fills the entire rest of the row/column.  Without such a restriction
it would indeed be unstable, but we could perhaps still reserve the
entire row/column even if you don't use it.  That would still allow
for manual placement of cells overlapping.  For example:

.sidebar { grid-column: 1; grid-row: 1 / -2 of implicit; }
.footer { grid-column: 1 / -1; grid-row: span 1 / -1 of implicit; }

This makes a sidebar that runs the entire height of the grid, but
leaves the last row empty, and then puts a footer into the last row.
If the footer weren't there, we'd still prevent auto-flow from putting
anything into the first row, for sanity/stability reasons.

> What’s preventing you, in this case, to use a two-rows grid whose first row
> is a <nav> element containing the tabs (which could be a flex-box). Using a
> flexbox may allow line-wrapping once dividing into columns cannot possibly
> work given the content min-size and is therefore much better.

Flexbox doesn't allow for alignment and other 2d things. You can often
fake simple grids with a multiline flexbox, but it's not a general
replacement.

Subgrids would make this unnecessary, as you could just put all the
auto-flow items into a subgrid (only inheriting the column lines) and
then place that appropriately into the parent grid, but subgrids are
of uncertain status.

~TJ

Received on Monday, 13 July 2015 17:38:05 UTC