@supports
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 9ì.
* Some parts of this feature may have varying levels of support.
@supports CSS @ê·ì¹ì 주ì´ì§ íë ì´ìì CSS 기ë¥ì ë¸ë¼ì°ì ê° ì§ìíëì§ì ë°ë¼ ë¤ë¥¸ ì¤íì¼ ì ì¸ì í ì ìë ë°©ë²ì ì ê³µí©ëë¤. ì´ë¥¼ ê¸°ë¥ ì¿¼ë¦¬(feature query)ë¼ê³ ë¶ë¦
ëë¤. @supportsë ì¤íì¼ì ìµìì ë¨ê³, ëë ë¤ë¥¸ ì¡°ê±´ë¶ ê·¸ë£¹ ê·ì¹ì ì¤ì²©í´ ìì¹í ì ììµëë¤.
@supports (display: grid) {
div {
display: grid;
}
}
@supports not (display: grid) {
div {
float: right;
}
}
JavaScriptìì, @supportsë CSS ê°ì²´ ëª¨ë¸ ì¸í°íì´ì¤ CSSSupportsRuleë¡ ì ê·¼í ì ììµëë¤.
구문
@supports @ê·ì¹ì íëì ì ì¸ ë¸ë¡ì í¹ì 기ë¥ì ë¸ë¼ì°ì ì§ì ì¡°ê±´ê³¼ ì°ê²°í ì ììµëë¤. ì§ì ì¡°ê±´ì íë ì´ìì í¤-ê° ìì ë
¼ë¦¬ê³±(and), ë
¼ë¦¬í©(or), ë¶ì (notì¼ë¡ ì°ê²°í´ 구ì±í©ëë¤. ê´í¸ë¡ ë¬¶ì´ ì°ì ìì를 ì§ì í ìë ììµëë¤.
ì ì¸ êµ¬ë¬¸
ê°ì¥ 기본ì ì¸ ì§ì ì¡°ê±´ì ë¨ìí ì ì¸(ìì± ì´ë¦ê³¼ ê·¸ ê°)ì
ëë¤. ì ì¸ì ê´í¸ë¡ 묶ì¬ì¼ í©ëë¤. ë¤ì ìì ë ë¸ë¼ì°ì ê° transform-origin ìì±ì ê°ì¼ë¡ 5% 5%ê° ì í¨íë¤ê³ ì¬ê¸¸ ë íµê³¼í©ëë¤.
@supports (transform-origin: 5% 5%) {
}
í¨ì 구문
ë ë²ì§¸ 기본ì ì¸ ì§ì ì¡°ê±´ì ì§ì í¨ìë¡, 모ë ë¸ë¼ì°ì ê° í¨ì 구문ì ì§ìíì§ë§ ì§ì í¨ì ìì²´ë ìì§ íì¤í ì¤ì ëë¤.
selector()
ë¸ë¼ì°ì ê° ì£¼ì´ì§ ì íì를 ì§ìíëì§ íë³í©ëë¤. ë¤ì ìì ë ë¸ë¼ì°ì ê° ìì ê²°í©ì를 ì§ìí ë íµê³¼í©ëë¤.
@supports selector(A > B) {
}
not ì°ì°ì
not ì°ì°ì를 ì´ë¤ ííì ìì ë¶ì´ë©´ ê·¸ ë°ë 결과를 ë³ë ìë¡ì´ ííìì ìì±í©ëë¤. ë¤ì ìì ë ë¸ë¼ì°ì ê° transform-origin ìì±ì ê°ì¼ë¡ 10em 10em 10emì´ ì í¨íì§ ìë¤ê³ ì¬ê¸¸ ë íµê³¼í©ëë¤.
@supports not (transform-origin: 10em 10em 10em) {
}
ë¤ë¥¸ ì°ì°ìì ë§ì°¬ê°ì§ë¡, ì ì¸ì ë³µì¡ëì ê´ê³ ìì´ not ì°ì°ì를 ì ì©í ì ììµëë¤. ë¤ì ë ììë 모ë ì í¨í 구문ì
ëë¤.
@supports not (not (transform-origin: 2px)) {
}
@supports (display: grid) and (not (display: inline-grid)) {
}
ì°¸ê³ :
ìµìì not ì°ì°ìë ê´í¸ë¡ ê°ì¸ì§ ììë ê´ì°®ìµëë¤. and, or ë± ë¤ë¥¸ ì°ì°ìì í¨ê» ì¬ì©í ëë ê´í¸ê° íìí©ëë¤.
and ì°ì°ì
and ì°ì°ìë ë ííìì ë
¼ë¦¬ê³±ì¼ë¡ë¶í° ìë¡ì´ ííìì ìì±í©ëë¤. ìë¡ì´ ííìì ë êµ¬ì± ííìì´ ëª¨ë ì°¸ì¼ ëë§ ì°¸ì ë°íí©ëë¤. ë¤ì ìì ë ë ê°ì êµ¬ì± ííìì´ ëìì ì°¸ì´ì´ì¼ë§ íµê³¼í©ëë¤.
@supports (display: table-cell) and (display: list-item) {
}
ë¤ìì ë ¼ë¦¬ê³±ì ê´í¸ ìì´ ë³ì¹í ì ììµëë¤. ë¤ì ë ììë 모ë ì í¨í 구문ì ëë¤.
@supports (display: table-cell) and (display: list-item) and (display: run-in) {
}
@supports (display: table-cell) and ((display: list-item) and (display: run-in)) {
}
or ì°ì°ì
or ì°ì°ìë ë ííìì ë
¼ë¦¬í©ì¼ë¡ë¶í° ìë¡ì´ ííìì ìì±í©ëë¤. ìë¡ì´ ííìì ë êµ¬ì± ííì ì¤ ì´ë í 쪽ì´ë¼ë ì°¸ì´ë©´ ì°¸ì ë°íí©ëë¤. ë¤ì ìì ë ë ê°ì êµ¬ì± ííì ì¤ íëë¼ë ì°¸ì´ë©´ íµê³¼í©ëë¤.
@supports (transform-style: preserve) or (-moz-transform-style: preserve) {
}
ë¤ìì ë ¼ë¦¬í©ì ê´í¸ ìì´ ë³ì¹í ì ììµëë¤. ë¤ì ë ììë 모ë ì í¨í 구문ì ëë¤.
@supports (transform-style: preserve) or (-moz-transform-style: preserve) or
(-o-transform-style: preserve) or (-webkit-transform-style: preserve) {
}
@supports (transform-style: preserve-3d) or
(
(-moz-transform-style: preserve-3d) or
(
(-o-transform-style: preserve-3d) or
(-webkit-transform-style: preserve-3d)
)
) {
}
ì°¸ê³ :
andì or ì°ì°ì를 ê°ì´ ì¬ì©í ëë ê´í¸ë¥¼ ì¬ì©í´ ì°ì°ì ì ì© ìì를 ì ìí´ì¼ í©ëë¤. ê·¸ë ì§ ìì¼ë©´ ì¡°ê±´ì´ ì í¨íì§ ìì¼ë¯ë¡ @-ê·ì¹ ì 체를 무ìí©ëë¤.
íì 구문
@supports =
@supports <supports-condition> { <rule-list> }
<supports-condition> =
not <supports-in-parens> |
<supports-in-parens> [ and <supports-in-parens> ]* |
<supports-in-parens> [ or <supports-in-parens> ]*
<supports-in-parens> =
( <supports-condition> ) |
<supports-feature> |
<general-enclosed>
<supports-feature> =
<supports-selector-fn> |
<supports-font-tech-fn> |
<supports-font-format-fn> |
<supports-at-rule-fn> |
<supports-named-feature-fn> |
<supports-env-fn> |
<supports-decl>
<general-enclosed> =
[ <function-token> <any-value>? ) ] |
[ ( <any-value>? ) ]
<supports-selector-fn> =
selector( <complex-selector> )
<supports-font-tech-fn> =
font-tech( <font-tech> )
<supports-font-format-fn> =
font-format( <font-format> )
<supports-at-rule-fn> =
at-rule( <at-keyword-token> )
<supports-named-feature-fn> =
named-feature( <ident> )
<supports-env-fn> =
env( <ident> )
<supports-decl> =
( [ <declaration> | <supports-condition-name> ] )
<complex-selector> =
<complex-selector-unit> [ <combinator>? <complex-selector-unit> ]*
<font-tech> =
<font-features-tech> |
<color-font-tech> |
variations |
palettes |
incremental
<font-format> =
<string> |
collection |
embedded-opentype |
opentype |
svg |
truetype |
woff |
woff2
<complex-selector-unit> =
[ <compound-selector>? <pseudo-compound-selector>* ]!
<combinator> =
'>' |
'+' |
'~' |
[ '|' '|' ] |
[ / <wq-name> / ]
<font-features-tech> =
features-opentype |
features-aat |
features-graphite
<color-font-tech> =
color-COLRv0 |
color-COLRv1 |
color-SVG |
color-sbix |
color-CBDT
<compound-selector> =
[ <type-selector>? <subclass-selector>* ]!
<pseudo-compound-selector> =
<pseudo-element-selector> <pseudo-class-selector>*
<wq-name> =
<ns-prefix>? <ident-token>
<type-selector> =
<wq-name> |
<ns-prefix>? '*'
<subclass-selector> =
<id-selector> |
<class-selector> |
<attribute-selector> |
<pseudo-class-selector>
<pseudo-element-selector> =
: <pseudo-class-selector> |
<legacy-pseudo-element-selector>
<pseudo-class-selector> =
: <ident-token> |
: <function-token> <any-value> )
<ns-prefix> =
[ <ident-token> | '*' ]? '|'
<id-selector> =
<hash-token>
<class-selector> =
'.' <ident-token>
<attribute-selector> =
'[' <wq-name> ']' |
'[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'
<legacy-pseudo-element-selector> =
: [ before | after | first-line | first-letter ]
<attr-matcher> =
[ '~' | '|' | '^' | '$' | '*' ]? '='
<attr-modifier> =
i |
s
ìì
>주ì´ì§ CSS ìì±ì ì§ì ì¬ë¶ íë³
@supports (animation-name: test) {
⦠/* ì ëë©ì´ì
ìì±ì ì ëì¬ ìì´ ì¬ì©í ì ìì ë CSS ì ì© */
@keyframes { /* ë¤ë¥¸ @-ê·ì¹ì ì¤ì²© ê°ë¥ */
â¦
}
}
주ì´ì§ CSS ìì± ë° ì ëì¬ ë²ì ì ì§ì ì¬ë¶ íë³
@supports ( (perspective: 10px) or (-moz-perspective: 10px) or (-webkit-perspective: 10px) or
(-ms-perspective: 10px) or (-o-perspective: 10px) ) {
⦠/* ì ëì¬ê° ë¶ëë¼ë 3D ë³íì ì§ìíë©´ CSS ì ì© */
}
í¹ì CSS ìì±ì 미ì§ì ì¬ë¶ íë³
@supports not ((text-align-last: justify) or (-moz-text-align-last: justify) ){
⦠/* text-align-last: justify를 ëì²´í CSS */
}
ì¬ì©ì ì ì ìì± ì§ì ì¬ë¶ íë³
@supports (--foo: green) {
body {
color: var(--varName);
}
}
ì íì ì§ì ì¬ë¶ íë³ (ì: :is())
Experimental: ì´ ê¸°ë¥ì ì¤íì ì¸ ê¸°ë¥ì
ëë¤.
íë¡ëì
íê²½ìì ì¬ì©í기 ì ì ë¸ë¼ì°ì í¸íì± í를 주ì ê¹ê² íì¸íì¸ì.
/* :is()를 ì§ìíì§ ìë ë¸ë¼ì°ì ììë 무ìí¨ */
:is(ul, ol) > li {
⦠/* :is() ì íì를 ì§ìí ë ì ì©í CSS */
}
@supports not selector(:is(a, b)) {
/* :is()를 ì§ìíì§ ìì ë ëì²´í CSS */
ul > li,
ol > li {
⦠/* :is()를 ì§ìíì§ ìì ë ì ì©í CSS */
}
}
@supports selector(:nth-child(1n of a, b)) {
/* @supportsë¡ ë¨¼ì ë¬¶ì§ ìì¼ë©´ :nth-child()ì of 구문ì
ì§ìíì§ ìë ë¸ë¼ì°ì ìì ì¤íì¼ì ì못 ì ì©í ì ìì */
:is(:nth-child(1n of ul, ol) a,
details > summary) {
⦠/* :is() ì íìì :nth-child()ì of 구문ì ì§ìí ë ì ì©í CSS */
}
}
ëª ì¸
| Specification |
|---|
| CSS Conditional Rules Module Level 5 > # at-supports-ext > |
| CSS Conditional Rules Module Level 4 > # at-supports-ext > |
| CSS Conditional Rules Module Level 3 > # at-supports > |
ë¸ë¼ì°ì í¸íì±
ê°ì´ 보기
- CSSOM í´ëì¤
CSSSupportsRuleê³¼, JavaScript를 íµí´ ëì¼í íë³ì ìíí ì ìëCSS.supportsë©ìë