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>


결과보기



분류 제목
selector CSS - :nth-child() 가상선택자 ★ - 그 부모의 n번째 자식요소 (=nth-child선택자 =…
background CSS - background 속성 ★ - 배경 일괄 (= background속성 = 백그라운드속성)
animation CSS - animation-direction 속성 - 애니방향 (= 움직임방향 = 애니메이션디렉션속성, I…
responsive CSS - Responsive Image - (반응형 이미지) ★★★
flex CSS - flex-wrap 속성(C) ★ - 아이템 줄바꿈 가능 여부. (= flex-wrap속성 = 플렉…
text CSS - text-indent 속성 ★★ - 단락 첫줄 텍스트 들여쓰기 (= text-indent속성 = …
selector CSS - :active 가상선택자 - 링크클릭순간 (= 액티브선택자, 링크선택자)
box CSS - max-width 속성 - 최대너비 (= 최대가로길이 = max-width속성 = 맥스위드스속성)
list CSS - list-style-type 속성 ★ - 리스트 스타일 타입 (= 리스트 마커 종류 = list-…
responsive CSS - Viewport ★ - 사용자에게 보이는 웹페이지 영역 (= 메타태그 뷰포트 ※ 반응형 필수조건 …
css CSS - cursor 속성 - 커서 모양 (= cursor속성 = 커서속성)
box CSS - min-width 속성 - 최소너비 (=최소가로길이 = min-width속성 = 민위드스속성)
selector CSS - :visited 가상선택자 ★ -이미 방문한 링크 선택 (= 읽은글/방문글/확인글 표시 = 비지티…
border CSS - border-radius 속성 ★ - 테두리둥글기 지정 (= border-radius속성 = 보더…
intro CSS - inherit (인헤리트) - 상속개념 ★
29/34
목록
 홈  PC버전 로그인 일본어
그누앞단언어 14
그누뒷단언어
그외코딩언어
그누보드 1
제작의뢰
Q&A
커뮤니티
웹유틸
회원센터
홈짱닷컴 PC버전 로그인