-
Notifications
You must be signed in to change notification settings - Fork 680
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
[css-grid-N] Flowing grid items together #9098
Comments
I don’t want to jinx this proposal, but there are likely a lot of considerations we already hammered out around general named flows that we should apply to grid-flows. |
Nah this actually avoids virtually all of the issues with general flows. It just slaps a wrapper around siblings. |
Yup! |
Historical note: Bert's original (grid) template layout proposal had a feature like this. https://www.w3.org/TR/css-template-3/ |
Yup, specifically in https://www.w3.org/TR/css-template-3/#flow. The behavior was essentially what is defined here, it just named the pseudo-element It did have a way to target empty slots, which is interesting. |
Would love to know if this has been thought about being accepted. CSS Grids would become so powerful for reordering elements for different breakpoints |
Would it be possible to auto-generate Say that you want to layout an article with grid, and place most items in a centered text-column. Wrapping these elements with a Every now and then you might want an element to pop out of the column and use different grid tracks. After the popout element you really want to start a new Would it be possible automatically generate separate <article>
<!-- start of ::grid-flow(--text 1) -->
<h1>Title</h1>
<p>Text...</p>
<p>Some more text...</p>
<!-- end of ::grid-flow(--text 1) -->
<img class=popout />
<!-- start of ::grid-flow(--text 2) -->
<h2>Subtitle</h2>
<p>Some more text..</p>
<!-- end of ::grid-flow(--text 2) -->
</article> article {
display: grid;
grid-template-columns:
[popout-start] minmax(20px, 1fr)
[text-start] minmax(auto, 600px)
[text-end] minmax(20px, 1fr)
[popout-end];
}
article > :is(h1, h2, p, img) {
grid-flow: --text;
}
article::grid-flow(--text /* auto/adjacent? */) {
grid-column: text-start / text-end;
}
article > .popout {
grid-column: popout-start / popout-end;
grid-flow: none;
} |
Problem: There are several situations where authors want to use a particular DOM structure for semantic reasons, but want to rearrange the elements on layout. Grid (and other layout methods) can do this to some extent, but when the rearrangement would involve wrapping a container around some of the elements, it's impossible. This proposal aims to solve a limited subset of these use-cases, that should be sufficiently useful, widely implementable, and have minimal (ideally, none) accessibility implications.
Examples:
<h2>...</h2><section>...</section><h2>...</h2><section>...</section>
, but author wants to display it as tabs, with theh2
s collected together into a flexbox and only one section showing at a time.Complications to Avoid:
display: contents
and its ability to remove an a11y-significant parent from the tree. If possible, we should avoid changing the layout tree in major ways; ideally don't reparent anything, just rearrange.display: contents
which is a local transform.Proposal:
grid-flow: <<dashed-ident>> <<integer>>?
property, valid on in-flow grid items. It indicates that the grid item will be reparented in a group with other grid items using the same ident. (They are sorted by integer, then by DOM order, identical to how auto-flow works with the 'order' property.)::grid-flow(<<dashed-ident>>)
. Each distinct ident refers to a separate pseudo-element. It's an anonymous block, treated as a grid item of the container, that holds all the reflowed grid items with the matching ident. It's tree-abiding and can take all properties, so you can position it in the grid, set background/border, set overflow, make it a flexbox, etc.Details:
display: list-item
, as list items are reflected specially in the a11y tree. (TODO: figure out what the full set of a11y-significant properties/values are and decide how much we want to restrict things.)Additional Notes:
::grid-flow()
to exist even if nothing is flowed into it, for stable layouts - an area might have items in it only conditionally, but you still want to display the (empty) area itself. This solves the "decorative grid pseudo-elements" issue as well, which will make people happy.Questions:
display:contents
debacle.Examples using this proposal:
The text was updated successfully, but these errors were encountered: