-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
183 lines (134 loc) · 3.12 KB
/
index.md
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
---
title: gap
slug: Web/CSS/gap
l10n:
sourceCommit: 7dea2fa2c2562a8f441dfca779a08ae363334a13
---
{{CSSRef}}
[CSS](/ko/docs/Web/CSS) **`gap`** 속성은 행과 열 사이의 간격 ({{glossary("gutters")}})을 설정합니다. {{CSSxRef("row-gap")}}과 {{CSSxRef("column-gap")}}의 [단축 속성](/ko/docs/Web/CSS/Shorthand_properties)입니다.
{{EmbedInteractiveExample("pages/css/gap.html")}}
`grid-gap` 은 해당 속성의 별칭입니다.
## 구문
```css
/* 단일 <length> 값 */
gap: 20px;
gap: 1em;
gap: 3vmin;
gap: 0.5cm;
/* 단일 <percentage> 값 */
gap: 16%;
gap: 100%;
/* 이중 <length> 값 */
gap: 20px 10px;
gap: 1em 0.5em;
gap: 3vmin 2vmax;
gap: 0.5cm 2mm;
/* 이중 또는 혼합 <percentage> 값 */
gap: 16% 100%;
gap: 21px 82%;
/* calc() 값 */
gap: calc(10% + 20px);
gap: calc(20px + 10%) calc(10% - 5px);
/* 전역 값 */
gap: inherit;
gap: initial;
gap: unset;
gap: revert;
gap: revert-layer;
```
`gap`은 `<'row-gap'>` 값을 사용해 지정하며, 선택적으로 `<'column-gap'>`을 추가할 수 있습니다. `<'column-gap'>`을 생략한 경우 `<'row-gap'>`과 동일한 값을 사용합니다.
`<'row-gap'>`과 `<'column-gap'>`은 각각 `<length>` 또는 `<percentage>`를 사용해 지정합니다.
### 값
- {{CSSxRef("<length>")}}
- : 그리드 선을 분할하는 간격의 너비.
- {{CSSxRef("<percentage>")}}
- : 그리드 선을 분할하는 간격의 너비. 요소 크기에 상대적입니다.
### 형식 정의
{{cssinfo}}
### 형식 구문
{{CSSSyntax}}
## 예제
### 플렉스 레이아웃
#### HTML
```html
<div id="flexbox">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
```
#### CSS
```css
#flexbox {
display: flex;
flex-wrap: wrap;
width: 300px;
gap: 20px 5px;
}
#flexbox > div {
border: 1px solid green;
background-color: lime;
flex: 1 1 auto;
width: 100px;
height: 50px;
}
```
#### 결과
{{EmbedLiveSample("플렉스_레이아웃", "auto", "120px")}}
### 그리드 레이아웃
#### HTML
```html
<div id="grid">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
```
#### CSS
```css
#grid {
display: grid;
height: 200px;
grid-template: repeat(3, 1fr) / repeat(3, 1fr);
gap: 20px 5px;
}
#grid > div {
border: 1px solid green;
background-color: lime;
}
```
#### 결과
{{EmbedLiveSample("그리드_레이아웃", "auto", "120px")}}
### 다열 레이아웃
#### HTML
```html
<p class="content-box">
This is some multi-column text with a 40px column gap created with the CSS
<code>gap</code> property. Don't you think that's fun and exciting? I sure do!
</p>
```
#### CSS
```css
.content-box {
column-count: 3;
gap: 40px;
}
```
#### 결과
{{EmbedLiveSample("다열_레이아웃", "auto", "120px")}}
## 명세
{{Specifications}}
## 브라우저 호환성
{{Compat}}
## 같이 보기
- 관련 CSS 속성: {{CSSxRef("row-gap")}}, {{CSSxRef("column-gap")}}
- 그리드 레이아웃 안내서: _[Basic concepts of grid layout - Gutters](/ko/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout#Gutters)_