-
Notifications
You must be signed in to change notification settings - Fork 715
[css-cascade-6] Proposal: "until" pseudo selector #8815
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
There is already a proposal that would let you do this: #7233 div.active ~~ a { color: red; }
div:not(.active) ~~ a { color: initial; } |
Or possibly something like this (if I'm reading #7751 correctly): @scope-siblings (div.active) to (div) {
a { color: red; }
} @mirisuzanne Is that right? I haven't been following this in detail. |
Going back to the specific proposal, I don't like that div.active ~(:not(div)) a { color: red } So But not sure if something like this is worth it if |
The sibling scope at-rule will work for this use-case, @bramus is working on spec text for that. The issue with doing it as a pseudo-class (which we considered) is related to @Loirooriol's comment: the 'scope-end' element has to be defined in relation to a specific 'scope-start' element, and the selector subject has to be defined in relation to that resulting scope. That means we need to match three distinct selectors to three distinct subjects. There might be ways to do that in a pseudo-class or other selector syntax, but so far it seems clearer in an at-rule, where each of the three selectors has it's own space. |
Yup, this is an @scope issue, and doing it within the Selector syntax itself is fraught. |
Uh oh!
There was an error while loading. Please reload this page.
Following my StackOverflow question
I would like to propose a pseudo-selector for selecting elements until the selector defined in the
:until
part is encountered.The main purpose is a repeating selector, for confined "groups" of matched elements, between certain constraints.
Use-cases for an
:until
pseudo-selector:For each
div
with classactive
select all of its following (next)<a>
siblings up until the first encountereddiv
selector (jsbin).(the number of
<a>
elements is unknown)Currently, there is a specificity problem if one simply write the below CSS selectors:
The selectors only match the first "group" of ` elements and then the second selector overrides the first selector for the rest of the anchor elements:
The text was updated successfully, but these errors were encountered: