display: grid
display 속성은 요소를 어떻게 보여줄지를 결정.
즉, 웹 페이지의 레이아웃을 결정하는 CSS의 속성 중 하나이다.
.container {
display: grid;
}
dispaly gird는 2차원(행과 열)의 레이아웃을 만들 수 있다.
예를 들어 아래와 같이 레이아웃을 만들 수 있다.
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
grid-template-columns와 gird-template-rows 로 행과 열의 크기를 자유롭게 조절할 수 있다.
px로 크기를 지정해 줄 수도 있고 fr(fraction, 공간 비율)로 비율 단위로 크기를 조절할 수도 있다.
.container {
display: grid;
grid-template-rows: 200px 150px 150px;
grid-template-columns: 1fr 1fr 1fr;
}
또한 justify-content와 align-items로 행과 열의 정열을 맞출 수 있다.
justify-content로 행 축(수평)을 정렬하고 align-items로 열 축(수직)을 정렬한다.
.container {
display: grid;
grid-template-rows: 200px 150px 150px;
grid-template-columns: 1fr 1fr 1fr;
justify-content: center;
align-items: center;
}
'코딩공부' 카테고리의 다른 글
[python] 재귀함수 회문 검사 / TIL_220920 (0) | 2022.09.20 |
---|---|
[python] 재귀함수(Recursive Function) / TIL_220919 (0) | 2022.09.19 |
[python]set 집합 자료형 함수 / TIL_220916 (0) | 2022.09.16 |
[python]args, kwargs / TIL_220915 (0) | 2022.09.15 |
python map 함수 _ TIL 4일차 (0) | 2022.09.01 |
댓글