grid
grid
CSS 속성은 shorthand property 입니다. 외재적인 속성인 (grid-template-rows
(en-US), grid-template-columns
, grid-template-areas
(en-US)), 값과 내재적인 속성인 (grid-auto-rows
(en-US), grid-auto-columns
(en-US), grid-auto-flow
(en-US)), 값을 한번에 설정합니다.
시도해보기
참고: You can only specify the explicit or the implicit grid properties in a single grid
declaration. The sub-properties you don’t specify are set to their initial value, as normal for shorthands. Also, the gutter properties are NOT reset by this shorthand.
Syntax
/* <'grid-template'> values */
grid: none;
grid: "a" 100px "b" 1fr;
grid: [linename1] "a" 100px [linename2];
grid: "a" 200px "b" min-content;
grid: "a" minmax(100px, max-content) "b" 20%;
grid: 100px / 200px;
grid: minmax(400px, min-content) / repeat(auto-fill, 50px);
/* <'grid-template-rows'> /
[ auto-flow && dense? ] <'grid-auto-columns'>? values */
grid: 200px / auto-flow;
grid: 30% / auto-flow dense;
grid: repeat(3, [line1 line2 line3] 200px) / auto-flow 300px;
grid: [line1] minmax(20em, max-content) / auto-flow dense 40%;
/* [ auto-flow && dense? ] <'grid-auto-rows'>? /
<'grid-template-columns'> values */
grid: auto-flow / 200px;
grid: auto-flow dense / 30%;
grid: auto-flow 300px / repeat(3, [line1 line2 line3] 200px);
grid: auto-flow dense 40% / [line1] minmax(20em, max-content);
/* Global values */
grid: inherit;
grid: initial;
grid: unset;
Values
<'grid-template'>
-
grid-template-columns
,grid-template-rows
(en-US),grid-template-areas
(en-US) 값을 내포하고 있는grid-template
(en-US)의 값을 정의합니다. <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>?
-
grid-template-rows
(en-US) (and thegrid-template-columns
property tonone
)은 auto-flow 값을 설정합니다.grid-auto-columns
(en-US) (and settinggrid-auto-rows
(en-US) toauto
)은 auto-repeat를 설정합니다.grid-auto-flow
(en-US) 또한 마찬가지로 auto-repeat에 영향을 줍니다. 만약 이 값이 생략되었다면 그 기본값은dense
입니다.만약 grid
의 sub-properties가 있다면, 해당 값으로 초기화 됩니다. [ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'>
-
grid-template-columns
(and thegrid-template-rows
(en-US) property tonone
)은 auto-flow 값을 설정합니다.grid-auto-rows
(en-US) (and settinggrid-auto-columns
(en-US) toauto
)은 열(row)에 대한 auto-repeat를 설정합니다.grid-auto-flow
(en-US) 또한 마찬가지로 auto-repeat에 영향을 줍니다. 만약 이 값이 생략되었다면 그 기본값은dense
입니다.만약 grid
의 sub-properties가 있다면, 해당 값으로 초기화 됩니다.
Formal syntax
Example
HTML Content
<div id="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS Content
#container {
display: grid;
grid: repeat(2, 60px) / auto-flow 80px;
}
#container > div {
background-color: #8ca0ff;
width: 50px;
height: 50px;
}
Result
명세서
Specification |
---|
CSS Grid Layout Module Level 2 # grid-shorthand |
초기값 | as each of the properties of the shorthand:
|
---|---|
적용대상 | grid containers |
상속 | no |
Percentages | as each of the properties of the shorthand:
|
계산 값 | as each of the properties of the shorthand:
|
Animation type | discrete |
브라우저 호환성
BCD tables only load in the browser
See also
- Related CSS properties:
grid-template
(en-US),grid-template-rows
(en-US),grid-template-columns
,grid-template-areas
(en-US),grid-auto-columns
(en-US),grid-auto-rows
(en-US),grid-auto-flow
(en-US) - Grid Layout Guide: Line-based placement with CSS Grid
- Grid Layout Guide: Grid template areas - Grid definition shorthands
- CSS
- CSS Reference
- CSS Grid Layout
- Guides
- Basics concepts of grid layout
- Relationship to other layout methods
- Line-based placement
- Grid template areas
- Layout using named grid lines
- Auto-placement in grid layout (en-US)
- Box alignment in grid layout (en-US)
- Grids, logical values and writing modes (en-US)
- CSS Grid Layout and Accessibility (en-US)
- CSS Grid Layout and Progressive Enhancement (en-US)
- Realizing common layouts using grids (en-US)
- Properties
- grid
- grid-area
- grid-auto-columns (en-US)
- grid-auto-flow (en-US)
- grid-auto-rows (en-US)
- grid-column (en-US)
- grid-column-end (en-US)
- grid-column-gap (en-US)
- grid-column-start (en-US)
- grid-gap (en-US)
- grid-row (en-US)
- grid-row-end (en-US)
- grid-row-gap (en-US)
- grid-row-start (en-US)
- grid-template (en-US)
- grid-template-areas (en-US)
- grid-template-columns
- grid-template-rows (en-US)
- Glossary