Skip to content

[css-values-5] allow container queries in if() if-test #12069

@bigandy

Description

@bigandy

Spec: https://drafts.csswg.org/css-values-5/#if-notation

Looking at the spec I can see that style queries and media queries are supported but not container size queries.

I would like to be able to style based on the dimensions of the container:

background-color: if(
    container(width > 1000px): green;
    container(width > 800px): orange;
    container(width > 600px): red;
    else: rebeccapurple;
);

this would eliminate a lot of repetition compared to without if():

background-color: rebeccapurple;

@container (width > 600px) {
    background-color: red;
}

@container (width > 800px) {
    background-color: orange;
}

@container (width > 1000px) {
    background-color: green;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions