and
, or
and not
. In this post I would like to tell, among other things, about the syntax of this CSS3 module and current support for its browsers.font-size
property in which we want to use the calc()
function to calculate the font size, and as an argument to this function we want to pass an expression that calculates the font size from the font size of the root body
element. But how many browsers support it today? Not much. And what to do with the rest? Using CSS3 conditions, the question will get this answer: body { font-size: 14px; } @supports (font-size: calc(1rem + 12px)) { h1 { font-size: calc(1rem + 12px); } } @supports not (font-size: calc(1rem + 12px)) { h1 { font-size: 26px; } }
@supports
rule precedes the conditional construction. A conditional expression is what is in parentheses, while parentheses are always required. We can combine conditional expressions with the operators and
and or
, and also deny expressions with not
. /* ! */ @supports (transition-property: color) or (animation-name: foo) and (transform: rotate(10deg)) { }
transition
or animation
) and ( transform
)] or [( transition
) or ( animation
and transform
)]? Unknown. That is why we have to use parentheses just as I did just now, describing possible options. The following variants of the same code will be correct. @supports ((transition-property: color) or (animation-name: foo)) and (transform: rotate(10deg)) { } @supports (transition-property: color) or ((animation-name: foo) and (transform: rotate(10deg))) { }
@supports
appeared in Firefox 17.0a1, that is, it is now in the Firefox Aurora branch and will be in Beta somewhere in October. I haven’t heard anything about support for other browsers yet (maybe someone from the browser will tell you). In Firefox 17 itself, this option may be disabled in the settings if developers decide that the specification is not stable enough yet.Source: https://habr.com/ru/post/154123/
All Articles