-
Notifications
You must be signed in to change notification settings - Fork 715
[css-grid] grid-item pseudo-class #4097
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
Comments
I'm not sure why a |
Keep in mind we have the specificity-adjustment pseudo-class, |
More to the point, this isn't actually possible to implement.
(I'm therefore closing this issue since its use case has been resolved and the originally proposed solution is not something we can actually implement) |
This is closely related to the problem described in https://wiki.csswg.org/faq#selectors-that-depend-on-layout |
Yeah, in general this is an impossible problem. Happily, tho, in most cases you're not pulling grid-container children out of flow, so you can just go ahead and assume that any children are grid items, and use the |
Uh oh!
There was an error while loading. Please reload this page.
I often set grid-item properties on elements which by design I shouldn’t have much context about. For example when laying out different children on a (reusable) parent grid-container. This results in having to match grid-items based on their specific attributes (e.g. class names).
It would be great to be able to set the layout logic on a parent and separate it from children.
Instead of:
We could have:
This way we wouldn’t have to assume much about grid-items.
As a workaround I’ve been using the
.parent > *
compound selector to match grid-items, but this is not ideal for potential specificity issues.A step further would match
.parent:grid-item
only when.parent
hasdisplay: grid
.I also see this principle loosely applying on flexbox parent-child relationship.
My argument is to set all layout logic on a parent and have children follow the rules while being completely context-agnostic.
Cheers!
The text was updated successfully, but these errors were encountered: