From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/css/selector_list/index.html | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 files/ko/web/css/selector_list/index.html (limited to 'files/ko/web/css/selector_list') diff --git a/files/ko/web/css/selector_list/index.html b/files/ko/web/css/selector_list/index.html new file mode 100644 index 0000000000..6d45de9430 --- /dev/null +++ b/files/ko/web/css/selector_list/index.html @@ -0,0 +1,101 @@ +--- +title: 선택자 목록 +slug: Web/CSS/Selector_list +tags: + - CSS + - Reference + - Selectors + - 선택자 +translation_of: Web/CSS/Selector_list +--- +
{{CSSRef}}
+ +

CSS 선택자 목록(,)은 일치하는 모든 요소를 선택합니다.

+ +
/* 모든 span과 div 요소 선택 */
+span,
+div {
+  border: red 2px solid;
+}
+ +

다수의 선택자를 쉼표 구분 목록에 넣어 스타일 시트 크기를 줄일 수 있습니다.

+ +

구문

+ +
element, element, element { style properties }
+ +

예제

+ +

한 줄 묶기

+ +

쉼표로 구분한 목록을 한 줄에 배치할 수 있습니다.

+ +
h1, h2, h3, h4, h5, h6 { font-family: helvetica; }
+
+ +

여러 줄 묶기

+ +

쉼표로 구분한 목록을 여러 줄에 배치할 수도 있습니다.

+ +
#main,
+.content,
+article {
+  font-size: 1.1em;
+}
+
+ +

선택자 목록 무효화

+ +

선택자 목록의 단점은, 다음의 두 경우가 서로 같지 않다는 점입니다.

+ +
h1 { font-family: sans-serif }
+h2:maybe-unsupported { font-family: sans-serif }
+h3 { font-family: sans-serif }
+ +
h1, h2:maybe-unsupported, h3 { font-family: sans-serif }
+ +

왜냐하면 목록 내의 하나의 선택자라도 브라우저가 지원하지 않으면 전체 목록을 무효화하기 때문입니다.

+ +

대응 방법은 {{CSSxRef(":is", ":is()")}} 선택자를 사용하는 것을 통해, 유효하지 않은 선택자를 무시하는 것입니다. 그러나 :is()가 명시도를 계산하는 방법으로 인해, 모든 선택자가 동일한 명시도를 갖게 되는 부작용이 있습니다.

+ +
h1 { font-family: sans-serif }
+h2:maybe-unsupported { font-family: sans-serif }
+h3 { font-family: sans-serif }
+ +
:is(h1, h2:maybe-unsupported, h3) { font-family: sans-serif }
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("CSS4 Selectors", "#grouping", "Selector Lists")}}{{Spec2("CSS4 Selectors")}}Renamed to "selector list"
{{SpecName('CSS1', '#grouping', 'grouping')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

{{Compat("css.selectors.list")}}

+ +

같이 보기

+ + -- cgit v1.2.3-54-g00ecf