Study/css

:not ()

더 멋진 세상을 꿈꾸는 개발자 2020. 6. 13. 12:16

 

 

 

부정(negation) CSS 가상 클래스 :not(X)는 인수로 간단한 선택자(selector) X를 취하는 기능 표기법이다.

X는 다른 부정 선택자를 포함해서는 안 된다.

 

 

구문


:not(selector) { style properties }

 

 

 

 

예제


//index.html
<p> Some text. </p>
<p class="classy"> Some other text. </p>
<span> One more text </span>
//index.css
p:not(.classy) {color: red;}
body:not(p) {color: green;}

위의 css 및 html이 주어진다면, 

 

 

이 같은 출력을 얻습니다:

 

Some text.

Some other text.

One more text

 

 

 

출처 : https://developer.mozilla.org/ko/docs/Web/CSS/:not