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/class_selectors/index.html | 107 ++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 files/ko/web/css/class_selectors/index.html (limited to 'files/ko/web/css/class_selectors') diff --git a/files/ko/web/css/class_selectors/index.html b/files/ko/web/css/class_selectors/index.html new file mode 100644 index 0000000000..70c84faa98 --- /dev/null +++ b/files/ko/web/css/class_selectors/index.html @@ -0,0 +1,107 @@ +--- +title: 클래스 선택자 +slug: Web/CSS/Class_selectors +tags: + - CSS + - Reference + - Selectors +translation_of: Web/CSS/Class_selectors +--- +
{{CSSRef}}
+ +

CSS 클래스 선택자는 요소의 {{htmlattrxref("class")}} 특성에 기반해 요소를 선택합니다.

+ +
/* All elements with class="spacious" */
+.spacious {
+  margin: 2em;
+}
+
+/* All <li> elements with class="spacious" */
+li.spacious {
+  margin: 2em;
+}
+
+/* All <li> elements with a class list that includes both "spacious" and "elegant" */
+/* For example, class="elegant retro spacious" */
+li.spacious.elegant {
+  margin: 2em;
+}
+
+ +

구문

+ +
.class_name { style properties }
+ +

위의 구문은 특성 선택자를 사용한 다음 구문과 동일합니다.

+ +
[class~=class_name] { style properties }
+ +

예제

+ +

CSS

+ +
.red {
+  color: #f33;
+}
+
+.yellow-bg {
+  background: #ffa;
+}
+
+.fancy {
+  font-weight: bold;
+  text-shadow: 4px 4px 3px #77f;
+}
+
+ +

HTML

+ +
<p class="red">빨간 글자색의 문단입니다.</p>
+<p class="red yellow-bg">빨간 글자색과 노란 배경의 문단입니다.</p>
+<p class="red fancy">빨간 글자색과 "멋진" 스타일을 가진 문단입니다.</p>
+<p>이건 그냥 문단이에요.</p>
+
+ +

결과

+ +

{{EmbedLiveSample('예제')}}

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS4 Selectors', '#class-html', 'class selectors')}}{{Spec2('CSS4 Selectors')}}No changes
{{SpecName('CSS3 Selectors', '#class-html', 'class selectors')}}{{Spec2('CSS3 Selectors')}}
{{SpecName('CSS2.1', 'selector.html#class-html', 'child selectors')}}{{Spec2('CSS2.1')}}
{{SpecName('CSS1', '#class-as-selector', 'child selectors')}}{{Spec2('CSS1')}}Initial definition
+ +

브라우저 호환성

+ + + +

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

-- cgit v1.2.3-54-g00ecf