blob: 1ce1a10a2b77d959e3e3bc23348e130ccf066ce8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
---
title: prefers-color-scheme
slug: Web/CSS/@media/prefers-color-scheme
tags:
- '@media'
- CSS
- Reference
- Web
- prefers-color-scheme
translation_of: Web/CSS/@media/prefers-color-scheme
---
<p><strong><code>prefers-color-scheme</code></strong> <a href="/ko/docs/CSS">CSS</a> <a href="/ko/docs/Web/CSS/@media#Media_features">미디어 특성</a>은 사용자의 시스템이 라이트 테마나 다크 테마를 사용하는지 탐지하는 데에 사용됩니다.</p>
<h2 id="구문">구문</h2>
<dl>
<dt><code><dfn>no-preference</dfn></code></dt>
<dd>사용자가 시스템에 선호하는 테마를 알리지 않았음을 나타냅니다. 이 키워드는 <a href="https://drafts.csswg.org/mediaqueries-5/#boolean-context" id="ref-for-boolean-context④">boolean context</a>에서 <code>false</code>로 판정됩니다.</dd>
<dt><code><dfn>light</dfn></code></dt>
<dd>사용자가 시스템에 라이트 테마를 사용하는 것을 선호한다고 알렸음을 나타냅니다.</dd>
<dt><code><dfn>dark</dfn></code></dt>
<dd>사용자가 시스템에 다크 테마를 사용하는 것을 선호한다고 알렸음을 나타냅니다.</dd>
</dl>
<h2 id="예제">예제</h2>
<p>이 예제는 검은 배경에 흰 텍스트를 가진 요소를 라이트 테마를 사용하는 사용자가 볼 경우 색을 반대로 해서 나타냅니다.</p>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><div class="themed">Theme</div>
</pre>
<h3 id="CSS">CSS</h3>
<pre class="brush: css">.themed {
display: block;
width: 10em;
height: 10em;
background: black;
color: white;
}
@media (prefers-color-scheme: light) {
.themed {
background: white;
color: black;
}
}
</pre>
<h3 id="Result">Result</h3>
<p>{{EmbedLiveSample("예제")}}</p>
<h2 id="명세">명세</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>{{SpecName('CSS5 Media Queries', '#descdef-media-prefers-color-scheme', 'prefers-color-scheme')}}</p>
</td>
<td>{{Spec2('CSS5 Media Queries')}}</td>
<td>초기 정의.</td>
</tr>
</tbody>
</table>
<h2 id="브라우저_호환성">브라우저 호환성</h2>
<p>{{Compat("css.at-rules.media.prefers-color-scheme")}}</p>
<h2 id="같이_보기">같이 보기</h2>
<ul>
<li><a href="https://stuffandnonsense.co.uk/blog/redesigning-your-product-and-website-for-dark-mode">Redesigning your product and website for dark mode</a></li>
</ul>
<div>{{QuickLinksWithSubpages("/en-US/docs/Web/CSS/@media/")}}</div>
|