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

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

 

결과보기



분류 제목
text CSS - writing-mode 속성 - 텍스트 방향 가로/세로 제어. (= 글쓰기 방향 = 쓰기 모드 제…
css CSS - pointer-events 속성 - 마우스이벤트에 대한 반응 여부 (= pointer-events…
css CSS - hanging-punctuation 속성 - 문장부호 위치 지정 (= hanging-punctua…
css CSS - 자식요소 앞에 순번 붙이기 (= 번호 매기기 = 색인번호 추가 = 요소 카운팅)
selector CSS - :indeterminate 선택자 - 불확정요소 선택 (= :indeterminate선택자 = 인…
css CSS - 구글 로그인 포커스 애니 효과 (Google Logn Foucs Animation Effect) …
selector CSS - :placeholder-shown 선택자 - 플레이스홀더 텍스트 표시 중인 요소 선택 (= :pl…
css CSS - 이미지 세로 나열 (= 수직 정렬) 방법/경우/원인/이유
selector CSS - ::-webkit-scrollbar - 스크롤바 선택자 (= 스크롤바 모양 디자인 커스텀 = Cu…
box CSS - block-size 속성 - 블락 방향으로 요소 크기 지정 (= block-size속성 = 블락…
box CSS - inline-size 속성 - 인라인방향으로 요소 크기 지정 (= inline-size속성 = 인…
text CSS - overflow-wrap 속성 - 줄바꿈 위해 단어 쪼개기 (= overflow-wrap속성 = …
background CSS - Multi Background 구문 - 한번에 여러 배경 속성값 사용
selector CSS - ::placeholder 선택자 - 플레이스홀더 선택자
css CSS - 인스타그램(instagram) 배경색 효과
css CSS - currentcolor 키워드 - 현재 글자색 속성값을 그대로 사용 (= 커런트컬러 속성값)
image CSS - object-fit 속성 - 컨테이너에 맞게 '이미지/비디오' 크기 조정 방법 지정 (= obje…
image CSS - object-position 속성 - <img>/<video>가 "자체 콘텐츠 상자" 내부의 x/…
css CSS - 코드펜 스타트 코딩 버튼 테두리 효과 (Codepen Start Coding Button Bord…
css CSS - translate 속성 - 2D/3D 상 요소 위치 좌표 변경 지정 (= translate속성 =…
16/25
목록
찾아주셔서 감사합니다. Since 2012