CSS 그리드 속성
예시
첫 번째 행의 높이가 150px인 3열 그리드 레이아웃을 만듭니다.
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
정의 및 사용
속성은 다음 grid
에 대한 약식 속성입니다.
기본값: | 없음 없음 없음 자동 자동 행 |
---|---|
상속: | 아니요 |
애니메이션 가능: | 예, 개별 속성을 참조하십시오 . 애니메이션 가능 에 대해 읽기 |
버전: | CSS 그리드 레이아웃 모듈 레벨 1 |
자바스크립트 구문: | object .style.grid="250px / 자동 자동 자동" |
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
CSS 구문
grid: none|grid-template-rows /
grid-template-columns|grid-template-areas|grid-template-rows
/ [grid-auto-flow] grid-auto-columns|[grid-auto-flow] grid-auto-rows / grid-template-columns|initial|inherit;
속성 값
Value | Description | Play it |
---|---|---|
none | Default value. No specific sizing of the columns or rows | |
grid-template-rows / grid-template-columns | Specifies the size(s) of the columns and rows | |
grid-template-areas | Specifies the grid layout using named items | |
grid-template-rows / grid-auto-columns | Specifies the size (height) of the rows, and the auto size of the columns | |
grid-auto-rows / grid-template-columns | Specifies the auto size of the rows, and sets the grid-template-columns property | |
grid-template-rows / grid-auto-flow grid-auto-columns | Specifies the size (height) of the rows, and how to place auto-placed items, and the auto size of the columns | |
grid-auto-flow grid-auto-rows / grid-template-columns | Specifies how to place auto-placed items, and the auto size of the rows, and sets the grid-template-columns property | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
더 많은 예
예시
두 개의 행을 지정합니다. 여기서 "item1"은 처음 두 행(5열 그리드 레이아웃에서)의 처음 두 열에 걸쳐 있습니다.
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
예시
모든 항목의 이름을 지정하고 바로 사용할 수 있는 웹 페이지 템플릿을 만듭니다.
.item1 { grid-area: header; }
.item2 { grid-area:
menu; }
.item3 { grid-area:
main; }
.item4 { grid-area:
right; }
.item5 { grid-area:
footer; }
.grid-container {
display: grid;
grid:
'header header header header header'
'menu main main main right right'
'menu footer footer
footer footer';
}
관련 페이지
CSS 튜토리얼: CSS 그리드 컨테이너
CSS 참조: grid-template-areas 속성
CSS 참조: grid-template-rows 속성
CSS 참조: grid-template-columns 속성
CSS 참조: grid-auto-rows 속성
CSS 참조: grid-auto-columns 속성
CSS 참조: grid-auto-flow 속성
CSS 참조: grid-row-gap 속성
CSS 참조: grid-column-gap 속성