CSS

[flex] CSS - flex-wrap 속성(C) ★ - 아이템 줄바꿈 가능 여부. (= flex-wrap속성 = 플렉스랩속성, IE11) ※ 플렉스 컨테이너용 속성

목차
  1. flex-wrap 예제 - wrap 경우, 줄바꿈 O + 아이템 순차 나열
  2. flex-wrap 정의
  3. flex-wrap 구문
  4. flex-wrap 예제 - nowrap 경우, 줄바꿈 X + 아이템 순차 나열
  5. flex-wrap 예제 - wrap-reverse 경우, 줄바꿈 O + 아이템 역순 나열

 

flex-wrap 예제 - wrap 경우, 줄바꿈 O + 아이템 순차 나열 

 

<style> 

#hz {

  width: 200px;

  height: 200px;

  border: 1px solid silver;

  display: -webkit-flex; /* Safari */

  -webkit-flex-wrap: wrap; /* Safari 6.1+ */

  display: flex;

  flex-wrap: wrap;

}


#hz div {

  width: 50px;

  height: 50px;

}

</style>


<div id="hz">

  <div style="background-color:coral;">A</div>

  <div style="background-color:lightblue;">B</div>

  <div style="background-color:khaki;">C</div>

  <div style="background-color:pink;">D</div>

  <div style="background-color:lightgrey;">E</div>

  <div style="background-color:lightgreen;">F</div>

</div>

 

결과보기

※ 4개는 위에, 2개는 밑에 정렬. (즉, 가로 너비 벗어나면 밑으로 내려감.)

 

flex-wrap 정의

 
플렉스 아이템 줄바꿈 가능 여부 선택.

 


 

1.

  • 요소가 플렉스아이템 아닌 경우, 적용 안 됨.
  • flex-flow 속성 - flex-direction 속성과 flex-wrap 속성을 일괄 지정.

 

2.

  • 기본값: nowrap
  • 상속여부: X
  • 애니효과: X
  • CSS버전: CSS3
  • JS구문: object.style.flexWrap="nowrap";

 

3.

IE 11 이상 주요 최신 브라우저 지원. (단, IE 11 경우, 부분 지원.)

 

4. MDN flex-wrap 예제 보기

https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap

 

 

flex-wrap 구문

 

selector {flex-wrap: nowrap|wrap|wrap-reverse|initial|inherit;}

 


[속성값]

 

nowrap

아이템 줄바꿈 허용 X (※ 필요 시, 아이템 크기 축소해 한 줄에 배치) (기본값)

 

wrap

아이템 줄바꿈 허용 O + 컨테이너 앞단부터  아이템 순차 나열


wrap-reverse

아이템 줄바꿈 허용 O + 컨테이너 끝단 왼편부터 아이템 역순 나열

  • 역순 의미: flex-direction:row 경우, 플렉스 상자 끝 왼쪽부터 채움. /  flex-direction:row 경우, 플렉스 상자 끝 오른쪽부터 채움. / flex-direction:column 경우, 플렉스 상자 왼쪽 상단부터 채움. / flex-direction:column-reverse 경우, 플렉스 상자 오른쪽 하단부터 채움./

 

initial

이 속성의 기본값으로 설정.

 

inherit

부모요소 속성값 상속.

 

 

flex-wrap 예제 - nowrap 경우, 줄바꿈 X + 아이템 순차 나열

 

<style> 

#hz {

  width: 200px;

  height: 200px;

  border: 1px solid silver;

  display: -webkit-flex; /* Safari */

  -webkit-flex-wrap: nowrap; /* Safari 6.1+ */

  display: flex;

  flex-wrap: nowrap;

}


#hz div {

  width: 50px;

  height: 50px;

}

</style>


<div id="hz">

  <div style="background-color:coral;">A</div>

  <div style="background-color:lightblue;">B</div>

  <div style="background-color:khaki;">C</div>

  <div style="background-color:pink;">D</div>

  <div style="background-color:lightgrey;">E</div>

  <div style="background-color:lightgreen;">F</div>

</div>

 

결과보기

※ 6개가 옆으로 나란히 정렬.

 

flex-wrap 예제 - wrap-reverse 경우, 줄바꿈 O + 아이템 역순 나열

 

<style> 

#hz {

  width: 200px;

  height: 200px;

  border: 1px solid silver;

  display: -webkit-flex; /* Safari */

  -webkit-flex-wrap: wrap-reverse; /* Safari 6.1+ */

  display: flex;

  flex-wrap: wrap-reverse;

}


#hz div {

  width: 50px;

  height: 50px;

}

</style>


<div id="hz">

  <div style="background-color:coral;">A</div>

  <div style="background-color:lightblue;">B</div>

  <div style="background-color:khaki;">C</div>

  <div style="background-color:pink;">D</div>

  <div style="background-color:lightgrey;">E</div>

  <div style="background-color:lightgreen;">F</div>

</div>


결과보기



분류 제목
transform CSS - perspective-origin 속성 - 3D요소 바라보는 위치 (= perspective-or…
transform CSS - backface-visibility 속성 - 3D요소 뒷면 노출 여부. (= backface-vi…
transition CSS - transition 속성 ★★★ - 지정시간 동안 천천히 변화 (= transition속성 = 트…
transition CSS - transition-delay 속성 - 트랜지션 시작 대기 시간 (= transition-dela…
transition CSS - transition-duration 속성 ★ - 트랜지션 완료에 걸리는 시간 (= transiti…
transition CSS - transition-property 속성 - 트랜지션 효과 적용할 속성명 지정 (= transit…
transition CSS - transition-timing-function 속성 - 트랜지션 속도변경곡선 (= transit…
animation CSS - @keyframes 구문 - 애니메이션 코드 사용 선언 (= 애니사용 = @keyframes속성 …
animation CSS - animation 속성 ★ - 애니메이션 단축속성 (= animation속성 = 애니메이션속성, …
animation CSS - animation-delay 속성 - 애니지연시간 (= 작동지연시간 = 작동대기시간 = 작동준비시…
animation CSS - animation-direction 속성 - 애니방향 (= 움직임방향 = 애니메이션디렉션속성, I…
animation CSS - animation-duration 속성 - 애니지속시간 (= 애니완료소요시간 = 움직임완료소요시간…
animation CSS - animation-fill-mode 속성 - 애니미작동스타일 (= 움직임 작동안할때 스타일 = 애…
animation CSS - animation-iteration-count 속성 - 애니반복횟수 (= 움직임반복횟수, IE10…
animation CSS - animation-name 속성 - 키프레임명 (= 키프레임이름 = 애니이름 = 애니명 = 애니메…
11/33
목록
 홈  PC버전 로그인 일본어
그누앞단언어 1
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 1
웹유틸
회원센터
홈짱닷컴 PC버전 로그인