CSS 그리드 템플릿 속성
예시
첫 번째 행의 높이가 150px인 3열 그리드 레이아웃을 만듭니다.
.grid-container {
display: grid;
grid-template: 150px
/ auto auto auto;
}
정의 및 사용
grid-template
속성은 다음 속성의 약식 속성입니다 .
기본값: | 없음 없음 없음 |
---|---|
상속: | 아니요 |
애니메이션 가능: | 예. 애니메이션 가능 에 대해 읽기 |
버전: | CSS 그리드 레이아웃 모듈 레벨 1 |
자바스크립트 구문: | 개체 .style.gridTemplate="250px / 자동 자동" |
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
grid-template | 57 | 16 | 52 | 10 | 44 |
CSS 구문
grid-template: none|grid-template-rows /
grid-template-columns|grid-template-areas|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 | |
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-template:
'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-template:
'header header header header header header'
'menu main main main right right'
'menu footer footer
footer footer footer';
}
관련 페이지
CSS 튜토리얼: CSS 그리드 아이템
CSS 참조: grid-area 속성
CSS 참조: grid-template-rows 속성
CSS 참조: grid-template-columns 속성
CSS 참조: grid-template-areas 속성