본문 바로가기
IT/css

css flex-direction 속성

by 뉴코딩맨 2023. 3. 24.
flex-direction 속성은 부모 요소가 display flex 일 때 자식 요소들을 좌측에서 우측, 우측에서 좌측, 상단에서 하단, 하단에서 상단 4가지 방향으로 위치 시킬 수 있습니다. 방향을 설정하지 않았을 때 기본값은 좌측에서 우측 뱡향입니다.
 

좌측에서 우측

 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #container {
        display: flex;
        flex-direction: row;
      }
      #container div {
        width: 100px;
        height: 100px;
      }
      #one {
        background-color: blue;
      }
      #two {
        background-color: blueviolet;
      }
      #three {
        background-color: brown;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="one"></div>
      <div id="two"></div>
      <div id="three"></div>
    </div>
  </body>
</html>

 

row-적용
row-적용

 

우측에서 좌측

 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #container {
        display: flex;
        flex-direction: row-reverse;
      }
      #container div {
        width: 100px;
        height: 100px;
      }
      #one {
        background-color: blue;
      }
      #two {
        background-color: blueviolet;
      }
      #three {
        background-color: brown;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="one"></div>
      <div id="two"></div>
      <div id="three"></div>
    </div>
  </body>
</html>

 

row-reverse-적용
row-reverse-적용

 

상단에서 하단

 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #container {
        display: flex;
        flex-direction: column;
      }
      #container div {
        width: 100px;
        height: 100px;
      }
      #one {
        background-color: blue;
      }
      #two {
        background-color: blueviolet;
      }
      #three {
        background-color: brown;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="one"></div>
      <div id="two"></div>
      <div id="three"></div>
    </div>
  </body>
</html>

 

column-적용
column-적용

 

하단에서 상단

 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #container {
        display: flex;
        flex-direction: column-reverse;
      }
      #container div {
        width: 100px;
        height: 100px;
      }
      #one {
        background-color: blue;
      }
      #two {
        background-color: blueviolet;
      }
      #three {
        background-color: brown;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="one"></div>
      <div id="two"></div>
      <div id="three"></div>
    </div>
  </body>
</html>

 

 
column-reverse-적용
column-reverse-적용

 

'IT > css' 카테고리의 다른 글

css flex-warp 속성  (0) 2023.03.24
css justify-content 속성  (0) 2023.03.24
css 투명도 조절하는 방법 - rgba, opacity  (0) 2023.03.23
css 단위 - %, em, rem  (0) 2023.03.23
css display 속성 - inline, block, inline-block, none  (0) 2023.03.23

댓글