• 회원가입
  • 로그인
  • 구글아이디로 로그인

[grid] CSS - grid-auto-flow 속성(C) - 그리드 컨테이너 채우는 방식 지정 (= grid-auto-flow속성 = 그리드오토플로우속성)

목차
  1. grid-auto-flow 예제 - 속성값이 (column / row) 경우 차이
  2. grid-auto-flow 정의
  3. grid-auto-flow 구문
  4. grid-auto-flow 예제 - 속성값이 (row / row dense) 경우 차이

 

grid-auto-flow 예제 - 속성값이 (column / row) 경우 차이

 

<style>

.grid-box {

  display: grid;

  grid-template-columns: auto auto auto;

  grid-template-rows: auto auto;

  grid-gap: 10px;

  background-color: pink;

  padding: 10px;

}


.grid-box.c {grid-auto-flow: column;}

.grid-box.r {grid-auto-flow: row;}


.grid-box > div {

  background-color: rgba(255, 255, 255, 0.8);

  text-align: center;

  padding: 10px 0;

  font-size: 30px;

}

</style>


<h2>grid-auto-flow: column</h2>

<div class="grid-box c">

  <div class="a">a</div>

  <div class="b">b</div>

  <div class="c">c</div>

  <div class="d">d</div>

</div>


<h2>grid-auto-flow: row</h2>

<div class="grid-box r">

  <div class="a">a</div>

  <div class="b">b</div>

  <div class="c">c</div>

  <div class="d">d</div>

</div>

 

결과보기

 

grid-auto-flow 정의

 

자동 배치된 아이템이 그리드 컨테이너를 채워나가는 방식을 지정.

 


 

1. 

이 속성이 지정 안 된 경우, 기본적으로 행(row) 기준으로 채워나감.

 

2.

  • 기본값: row
  • 상속여부: X
  • 애니가능: O
  • CSS버전: CSS Grid Layout Module Level 1
  • JS구문: object.style.gridAutoFlow="row dense";


3.

IE 제외한 주요 최신 브라우저 모두 지원.

 

4. MDN grid-auto-flow 예제보기

https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow

 

 

grid-auto-flow 구문

 

selector {grid-auto-flow: row|column|dense|row dense|column dense|initial|inherit;}

 


[속성값]

 

row 

행을 먼저 채워나감. (기본값)

 

column

열을 먼저 채워나감.

 

dense

구멍 메꾸며 채워나감.

 

row dense

행을 기준으로 채워나가되, 구멍 메꾸며 채워나감.

 

column dense

열을 기준으로 채워나가되, 구멍 메꾸며 채워나감.

 

initial

이 속성의 기본값 사용.

 

inherit

부모요소의 속성값 상속.

 

 

grid-auto-flow 예제 - 속성값이 (row / row dense) 경우 차이

 

<style>

.c { grid-column: auto / span 2; }


.grid-box {

  display: grid;

  grid-template-columns: auto auto auto;

  grid-template-rows: auto auto;

  grid-gap: 10px;

  background-color: pink;

  padding: 10px;

}


.grid-box.r {grid-auto-flow: row;}

.grid-box.rd {grid-auto-flow: row dense;}


.grid-box > div {

  background-color: rgba(255, 255, 255, 0.8);

  text-align: center;

  padding: 10px 0;

  font-size: 30px;

}

</style>


<h2>grid-auto-flow: row</h2>

<div class="grid-box r">

  <div class="a">a</div>

  <div class="b">b</div>

  <div class="c">c</div>

  <div class="d">d</div>

</div>


<h2>grid-auto-flow: row dense</h2>

<div class="grid-box rd">

  <div class="a">a</div>

  <div class="b">b</div>

  <div class="c">c</div>

  <div class="d">d</div>

</div>

 

결과보기



분류 제목
selector CSS - element,element 병렬선택자 ★ - 쉼표로 나열된 여러 요소 선택. (= 여러 요소선택…
box CSS - padding 속성 ★ - 안쪽여백 (= padding속성 = 패딩속성)
box CSS - min-height 속성 - 최소높이 (= 최소세로길이 = min-height속성 = 민하이트속성…
outline CSS - outline-style (아웃라인스타일) - 테두리 외곽 스타일 (상속 X) : (IE8)
intro CSS - @charset 구문 - 스타일시트 인코딩방식 설정 (= 언어셋지정/문자셋지정 = @charset…
border CSS - border-left 속성 - 테두리좌측일괄 (= 테두리왼쪽일괄 = border-left속성 = …
selector CSS - :last-child 가상선택자 - 그 부모의 마지막자식요소인 지정요소 (= :last-child…
selector CSS - :lang() 가상선택자 - 특정언어속성요소 (= 언어선택자 = 랭선택자, IE8)
list CSS - list-style-position 속성 ★ - 리스트 스타일 위치 (= 리스트 마커 위치 = …
box CSS - max-height 속성 - 최대높이 (= 최대세로길이 = max-height속성 = 맥스하이트속…
selector CSS - element>element 자식선택자 ★ - 직접 자식요소만 선택. (요소선택자, IE7)
animation CSS - animation-iteration-count 속성 - 애니반복횟수 (= 움직임반복횟수, IE10…
text CSS - writing-mode 속성 - 텍스트 방향 가로/세로 제어. (= 글쓰기 방향 = 쓰기 모드 제…
border CSS - border 속성 ★ - 테두리일괄 (= border속성 = 보더속성) (상속X)
func CSS - hsl() 함수 - (색조, 채도, 밝기)로 색상 정의. (= hsl함수 = 에이치에스엘함수/흐슬…
background CSS - background-attachment 속성 - 배경이미지 고정 (= background-atta…
background CSS - background 속성 ★ - 배경 일괄 (= background속성 = 백그라운드속성)
selector CSS - :nth-child() 가상선택자 ★ - 그 부모의 n번째 자식요소 (=nth-child선택자 =…
animation CSS - animation-direction 속성 - 애니방향 (= 움직임방향 = 애니메이션디렉션속성, I…
responsive CSS - Responsive Image - (반응형 이미지) ★★★
22/27
목록
찾아주셔서 감사합니다. Since 2012