Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using @container with Sass variables

Tags:

sass

I am trying to use the @container directive for breakpoints. It's working when I directly set the desired breakpoint like this:

@container (max-width: 992px) { // working
    span {
        background-color: green;
    }
}

However, when using variable for 992px it doesn't work. To asure that I used the variable correctly I added another style (max-height) which is working well.

max-height: $tablet; // results in max-height: 992px;

@container (max-width: $tablet) { // not working
    span {
        background-color: green;
    }
}
like image 765
michi-p Avatar asked Nov 18 '25 16:11

michi-p


1 Answers

As Amaury pointed out in the comments, I had to use the following syntax for using the variable:

@container (max-width: #{$tablet}) {
    span {
        background-color: green;
    }
}
like image 54
michi-p Avatar answered Nov 21 '25 08:11

michi-p



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!