-
Notifications
You must be signed in to change notification settings - Fork 683
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-contain-3] Multiple <container-query>s with multiple containers #6876
Comments
(I've already given this some further thought, and have identified that this could have a bigger impact. To not loiter the original post, I'm posting it as a reply) If this change were to be considered, then why not have the original example Would make sense with all elements being style containers by default 1. It would make these three examples below — where one is more explicit than the other about which container to target — behave in the same way: @container size(inline-size > 30em) and style(--responsive = true) {
.child {
/* styles */
}
}
@container wrapper size(inline-size > 30em) and style(--responsive = true) {
.child {
/* styles */
}
}
@container wrapper size(inline-size > 30em) and child style(--responsive = true) {
.child {
/* styles */
}
} Would also make a lot of sense when nesting @container size(inline-size > 30em) { /* Evaluate size() against nearest size container */
@container style(--responsive = true) { /* Evaluate style() against nearest style container, i.e. self */
.child {
…
}
}
} To have a /* As they are grouped using parens, evaluate both against wrapper */
@container wrapper (size(inline-size > 30em) and style(--responsive = true)) {
/* styles */
} In summary, the evaluation would always behave like this:
Footnotes |
First, to address some of the side issues:
But to focus in on the primary questions here: 1. Is it possible for one element to query multiple containers?[updated to reference current spec language]
Each @container size-wrapper size(inline-size > 30em) {
@container style-wrapper style(--responsive = true) {
.child { /* styles based on two different containers */ }
}
} Which simplifies this issue a bit more, down to just solving: 2. Do we want to allow that in a single
|
Would it then make sense to somehow associate the name/container-selection part with the corresponding condition in a way that's more visually obvious? E.g.
|
In #6644 (comment) we resolved that a single container query will select a single container to answer all its queries
|
I'll leave this issue open for now, since it's a reasonable bit of syntax sugar to consider down the road – but it seems we're not planning to address it in css-contain-3. Maybe I'll label as deferred. |
The spec currently reads (emphasis mine):
Applied to the example below, both conditions will be evaluated against
wrapper
What I want to have
size(inline-size > 30em)
be evaluated againstwrapper
andstyle(--responsive = true)
againstchild
(or any other wrapping container) ?Would it be feasible to pursue something like the snippet below, where it's allowed to set a
<container-name>
for each<container-query>
?The text was updated successfully, but these errors were encountered: