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

[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>

 

결과보기



분류 제목
transition CSS - transition-timing-function 속성 - 트랜지션 속도변경곡선 (= transit…
image CSS - object-position 속성 - <img>/<video>가 "자체 콘텐츠 상자" 내부의 x/…
pagination CSS - 페이징 - (이전페이지/다음페이지/지정페이지) 이동 링크 버튼
func CSS - 함수 종류
selector CSS - :only-of-type 가상선택자 - 타입유일 자식요소 (= 유일타입 자식요소) [유일선택자|타…
css CSS - 화면분할 좌측사이드 영역 스크롤 고정 (= 이미지/메뉴 사이드 고정)
transition CSS - transition-duration 속성 ★ - 트랜지션 완료에 걸리는 시간 (= transiti…
image CSS - Polaroid Images / Cards - (폴라로이드 이미지)
selector CSS - .class 클래스선택자 ★
pagination CSS - 페이징 - 테두리 추가 (Bordered Pagination)
background CSS - Multi Background 구문 - 한번에 여러 배경 속성값 사용
intro CSS - CSS3 입문
selector CSS - :root 가상선택자 - 웹문서root요소 선택. (= 루트선택자, IE9)
css CSS - 자식요소 앞에 순번 붙이기 (= 번호 매기기 = 색인번호 추가 = 요소 카운팅)
transition CSS - transition-delay 속성 - 트랜지션 시작 대기 시간 (= transition-dela…
image CSS - Rounded Images (둥근/동그란 이미지 만들기 = 이미지 테두리 둥글게/동그랗게) - I…
border CSS - border-bottom-right-radius 속성 - 테두리 하단 오른쪽 모서리 둥글게 (= …
image CSS - Image Filter - (이미지 필터 - 흑백/흐림 효과)
selector CSS - :in-range 가상선택자 - 지정범위안값 갖는 요소 선택 (= 인레인지선택자 IE13)
column CSS - columns 속성 - (컬럼최소너비/컬럼개수) 일괄 지정 (= columns속성 = 컬럼즈속성)
13/27
목록
찾아주셔서 감사합니다. Since 2012