aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/css/width/index.html
blob: 130c81148a6183740663f0303fa18032e6675382 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
title: width
slug: Web/CSS/width
tags:
  - CSS
  - CSS Property
  - Reference
translation_of: Web/CSS/width
---
<div>{{CSSRef}}</div>

<p>CSS <strong><code>width</code></strong> 속성은 요소의 너비를 설정합니다. 기본값은 콘텐츠 영역의 너비이지만, {{cssxref("box-sizing")}}<code>border-box</code>라면 테두리 영역의 너비를 설정합니다.</p>

<div>{{EmbedInteractiveExample("pages/css/width.html")}}</div>



<p>{{cssxref("min-width")}}{{cssxref("max-width")}} 속성은 <code>width</code>를 덮어씁니다.</p>

<h2 id="구문">구문</h2>

<pre class="brush:css no-line-numbers">/* &lt;length&gt; */
width: 300px;
width: 25em;

/* &lt;percentage&gt; */
width: 75%;

/* 키워드 */
width: 25em border-box;
width: 75% content-box;
width: max-content;
width: min-content;
width: available;
width: fit-content(20em);
width: auto;

/* 전역 값 */
width: inherit;
width: initial;
width: unset;
</pre>

<p><code>width</code> 속성은 다음과 같이 지정합니다.</p>

<ul>
 <li><code><a href="#min-content">min-content</a></code>, <code><a href="#max-content">max-content</a></code>, <code><a href="#fit-content">fit-content</a></code>, <code><a href="#auto">auto</a></code> 키워드 중 하나.</li>
 <li>하나의 <code><a href="#&lt;length>">&lt;length&gt;</a></code> 또는 <code><a href="#&lt;percentage>">&lt;percentage&gt;</a></code> 값.</li>
</ul>

<h3 id="값"></h3>

<dl>
 <dt><a id="&lt;length>" name="&lt;length>">{{cssxref("&lt;length&gt;")}}</a></dt>
 <dd>너비의 절댓값.</dd>
 <dt><a id="&lt;percentage>" name="&lt;percentage>">{{cssxref("&lt;percentage&gt;")}}</a></dt>
 <dd><a href="/ko/docs/Web/CSS/All_About_The_Containing_Block">컨테이닝 블록</a> 너비의 백분율. 컨테이닝 블록이 요소 너비에 영향을 받는 경우의 결과 레이아웃은 정해지지 않습니다.</dd>
 <dt><a id="auto" name="auto"><code>auto</code></a></dt>
 <dd>요소의 너비를 브라우저가 계산해 지정합니다.</dd>
 <dt><a id="max-content" name="max-content"><code>max-content</code></a></dt>
 <dd>본질적인 선호 너비.</dd>
 <dt><a id="min-content" name="min-content"><code>min-content</code></a></dt>
 <dd>본질적인 최소 너비.</dd>
 <dt id="fit-content"><a id="fit-content" name="fit-content"><code>fit-content({{cssxref("&lt;length-percentage&gt;")}}</code></a></dt>
 <dd><code>min(max-content, max(min-content, &lt;length-percentage&gt;))</code>의 결과.</dd>
</dl>

<h3 id="형식_구문">형식 구문</h3>

<pre class="syntaxbox">{{csssyntax}}</pre>

<h2 id="예제">예제</h2>

<h3 id="기본_너비">기본 너비</h3>

<pre class="brush:css">p.goldie {
  background: gold;
}</pre>

<pre class="brush:html">&lt;p class="goldie"&gt;모질라 커뮤니티는 많은 수의 대단한 소프트웨어를 제작합니다.&lt;/p&gt;</pre>

<p>{{EmbedLiveSample('기본_너비', '500px', '64px')}}</p>

<h3 id="px과_em"><code>px</code>과 <code>em</code></h3>

<pre class="brush: css">.px_length {
  width: 200px;
  background-color: red;
  color: white;
  border: 1px solid black;
}

.em_length {
  width: 20em;
  background-color: white;
  color: red;
  border: 1px solid black;
}
</pre>

<pre class="brush: html">&lt;div class="px_length"&gt;픽셀 너비&lt;/div&gt;
&lt;div class="em_length"&gt;em 너비&lt;/div&gt;</pre>

<p>{{EmbedLiveSample('px과_em', '500px', '64px')}}</p>

<h3 id="백분율">백분율</h3>

<pre class="brush: css">.percent {
  width: 20%;
  background-color: silver;
  border: 1px solid red;
}</pre>

<pre class="brush: html">&lt;div class="percent"&gt;백분율 너비&lt;/div&gt;</pre>

<p>{{EmbedLiveSample('백분율', '500px', '64px')}}</p>

<h3 id="max-content_2"><code>max-content</code></h3>

<pre class="brush:css;">p.maxgreen {
  background: lightgreen;
  width: intrinsic;           /* Safari/WebKit uses a non-standard name */
  width: -moz-max-content;    /* Firefox/Gecko */
  width: -webkit-max-content; /* Chrome */
  width: max-content;
}</pre>

<pre class="brush:html">&lt;p class="maxgreen"&gt;Mozilla 커뮤니티는 많은 수의 대단한 소프트웨어를 제작합니다.&lt;/p&gt;</pre>

<p>{{EmbedLiveSample('max-content_2', '500px', '64px')}}</p>

<h3 id="min-content_2"><code>min-content</code></h3>

<pre class="brush:css">p.minblue {
  background: lightblue;
  width: -moz-min-content;    /* Firefox */
  width: -webkit-min-content; /* Chrome */
  width: min-content;
}</pre>

<pre class="brush:html">&lt;p class="minblue"&gt;Mozilla 커뮤니티는 많은 수의 대단한 소프트웨어를 제작합니다.&lt;/p&gt;</pre>

<p>{{EmbedLiveSample('min-content_2', '500px', '155px')}}</p>

<h2 id="접근성_고려사항">접근성 고려사항</h2>

<p>페이지를 확대하거나 글꼴 크기를 늘렸을 때 <code>width</code> 속성을 지정한 요소가 잘리거나 다른 내용을 가리지 않도록 확인하세요.</p>

<ul>
 <li><a href="/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#Guideline_1.4_Make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background">MDN Understanding WCAG, Guideline 1.4 explanations</a></li>
 <li><a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-scale.html" rel="noopener">Understanding Success Criterion 1.4.4  | Understanding WCAG 2.0</a></li>
</ul>

<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>{{SpecName('CSS4 Sizing', '#width-height-keywords', 'width')}}</td>
   <td>{{Spec2('CSS4 Sizing')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Sizing', '#width-height-keywords', 'width')}}</td>
   <td>{{Spec2('CSS3 Sizing')}}</td>
   <td>Added the <code>max-content</code>, <code>min-content</code><code>fit-content</code> keywords.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'visudet.html#the-width-property', 'width')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Precises on which element it applies to.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS1', '#width', 'width')}}</td>
   <td>{{Spec2('CSS1')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<div>{{cssinfo}}</div>

<h2 id="브라우저_호환성">브라우저 호환성</h2>



<p>{{Compat("css.properties.width")}}</p>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li><a href="/ko/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model">박스 모델</a>, {{cssxref("height")}}, {{cssxref("box-sizing")}}, {{cssxref("min-width")}}, {{cssxref("max-width")}}</li>
</ul>