728x90
반응형
728x90
반응형
<!DOCTYPE html>
<html lang="ko">
<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>
    <!-- 
        1. Flexbox 부모 == container. 정렬할 자식을 가지는 요소
        1-1)* flex-direction:
            flex 컨테이너의 주측 방향을 설정한다 (row, column)
        1-2)* flex-wrap:
            flex 컨테이너의 item(자식들)을 한 줄, 여러줄 설정함 - wrap
            만약 요소의 크기가 커서 컨테이너를 벗어날 시, 밖으로 나와버림
            그럴 땐, overflow 속성으로 조절하면 된다.
        1-3) flex-flow:
            flex-direction 속성과 flex-wrap 속성을 함께 설정 기본 row nowrap
        1-4)* justify-content:
            flex의 컨테이너와 주축 기준으로 item들을 수평 정렬함
        1-5)* align-item:
            flex의 item들을 주축의 반대축방향으로 (교차방향으로)정렬 (수직정렬)
        1-6) align-content:
            flex의 컨테이너의 교차축을 기준으로 item들을 수직정렬한다.

        2. Flexbox 자식들 == item. 정렬당하는 요소들
            - float, clear, vertical-align 속성에 영향 받지 않음
        2-1) order:
            flex item의 배치 순서를 지정함. HTML 코드 변경 없이 재배치 가능
            기본 배치는 작성 순서. 같은 순서를 가지는 자식이 있으면 HTML코드 순번을 따름
            기본값:0, 높을수록 맨 뒤로 이동
        2-2) flex-grow:
            Flex item의 너비에 대한 확대정돌르 지정함. 기본값: 0, 음수는 x
        2-3) flex-shrink:
            flex item의 너비에 대한 축소정도를 지정함. 기본값:1, 음수는 x
            0을 지정하면 원래 형태로 돌아간다.(기존 너비값으로 함)
        2-4) flex-basis:
            Flex item의 너비 기본값을 정해준다. px, % 등의 단위로 지정함. 기본 auto
        2-5) flex:
        flex-grow, flex-shrink, flex-basis 속성을 함께 지정 할 수 있는 속성.
            기본값: 0 1 auto
        2-6) align-self:
            align-item 보다 우선적용
            수직방향으로 정렬
            Flex 컨테이너의 수직 방향 보다 우선 적용 되는 자신만의 정렬속성을 지정
    -->

     <style>
        #container {
            display: flex;
            position: absolute;
            background-color: beige;
            width: 1000px;
            height: 500px;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            font-weight: bold;
            overflow: scroll;

            justify-content: flex-start;
            flex-direction: row;
            flex-wrap: wrap;
            
            /* flex-direction: row;
            flex-wrap: wrap;
            justify-content: space-around;
            align-items: center;
            align-content: center; */

        }
        .item {
            box-sizing: border-box;
            border: 2px solid black;
            background-color: darkcyan;
            width: 150px;
            height: 50px;
        }

        .item1 {
            order:2;
        }

        .item2 {
            order: 2;
        }

        .item3 {
            flex-grow: 2;
        }
        
        .item4 {
            flex-grow: 5;
        }

        .item5 {
            flex-basis: 100px;
            align-self: stretch;
            /* flex-shrink: 5; */
        }



     </style>
</head>
<body>
    <div id="container">
        <div class="item item1">item1</div>
        <div class="item item2">item2</div>
        <div class="item item3">item3</div>
        <div class="item item4">item4</div>
        <div class="item item5">item5</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
    </div>
</body>
</html>
728x90
반응형

'정보 > WEB' 카테고리의 다른 글

js 기초  (0) 2023.01.01
요소 정렬 방법  (0) 2023.01.01
grid실습  (0) 2023.01.01
grid예제2  (0) 2023.01.01
grid 예제1  (0) 2023.01.01
728x90
반응형
<!DOCTYPE html>
<html lang="ko">
<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;
            width: 700px;
            box-sizing: border-box;
            border: 2px solid blue;
        }


        .box {
            width: 80px;
            margin: 5px;
            padding: 5px 45px;
            color: white;
            background-color: black;
        }

        #opt1 {
            flex-direction: row-reverse;
        }

        #opt2 {
            flex-direction: column;
        }
        #opt3 {
            flex-wrap: wrap;
        }

        #opt4 {
            height: 400px;
            flex-direction: row; /* 기준 축을 설정함*/
            /* 가운데 정렬 담당 비슷한 친구 */
            justify-content: flex-end; /* 기준 축 기준 오른쪽 정렬*/
            justify-content: flex-start; /* 기준 축 기준 왼쪽 정렬*/
            justify-content: space-around; /* 모든 공간에서 동일하게 나눠 가짐*/
            justify-content: space-between; /* 양쪽은 붙이고 나머지 공간은 동일하게 (주축간격)*/
            align-items: center; /* 기준축의 반대 축을 기준으로 정렬 (교차축 정렬)*/
            align-content: center; /* 기준축의 반대 축들의 요소들의 나눠 가지는 영역을 지정 (교차축간격)*/
        }

        #opt1 > div:first-child{
            flex: 1;
            background-color: aqua;
        }
        #opt1 > div:last-child{
            flex: 2;
            background-color: aqua;
        }




    </style>
</head>
<body>
    <div class="container" id="opt1">
        <div class="box"><p>1</p></div>
        <div class="box"><p>2</p></div>
        <div class="box"><p>3</p></div>
    </div>
    <div class="container" id="opt2">
        <div class="box"><p>1</p></div>
        <div class="box"><p>2</p></div>
        <div class="box"><p>3</p></div>
    </div>
    <div class="container" id="opt3">
        <div class="box"><p>1</p></div>
        <div class="box"><p>2</p></div>
        <div class="box"><p>3</p></div>
        <div class="box"><p>4</p></div>
        <div class="box"><p>5</p></div>
        <div class="box"><p>6</p></div>
        <div class="box"><p>7</p></div>
        <div class="box"><p>8</p></div>
        <div class="box"><p>9</p></div>
        <div class="box"><p>10</p></div>
    </div>
    <div class="container" id="opt4">
        <div class="box"><p>1</p></div>
        <div class="box"><p>2</p></div>
        <div class="box"><p>3</p></div>
    </div>
</body>
</html>

실행창

728x90
반응형

'정보 > WEB' 카테고리의 다른 글

grid예제2  (0) 2023.01.01
grid 예제1  (0) 2023.01.01
animation 예제2  (0) 2022.12.29
animation 예제1  (0) 2022.12.29
transform연습  (0) 2022.12.29
728x90
반응형
<!DOCTYPE html>
<html lang="ko">
    <head>
        <title>flex</title>
            <meta charset="UTF-8">
            <style>
                body > .flex-container {
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 250px;
                    /* height: 100%; */
                    background-color: rgb(238, 199, 27);
                    position: absolute;
                    /* transform: translateY(-50%); */
                   
                   
                    display: flex;
                    /* display : flex; > 해당 선택자에 의해 선택되는 요소가 가지는 자식요소의 정렬을 쉽게 할 수있음.*/
                    flex-direction: row;
                    /*flex-direction: 내부 자식 FLEX 방향
                        row : 가로방향으로
                        row-reverse : 가로 역방향으로
                        column : 세로방향으로
                        column-reverse : 세로 역방향으로
                    */

                    justify-content: center;
                    /* justify-content: flex-direction과 수평한 방향에 대한 정렬
                        flex-start : 시작점 정렬
                        center : 가운데
                        flex-end : 끝점 정렬
                    */
                    align-items: stretch;
                    /* align-items: flex-firection 과 수직한 방향에 대한 정렬
                        flex-start : 시작점 정렬
                        center : 가운데
                        flex-end : 끝점 정렬
                        stretch : 늘임
                    */
                   
                   
                }

                body > .flex-container > .s {
                    width: 100px;
                    /* height: 100px; */
                    background-color: rgb(0, 89, 255);
                }

                body > .flex-container > .r {
                    width: 50px;
                    /* height: 50px; */
                    /* background-color: rgb(0, 255, 149); */
                    border-radius: 50%;
                    flex-grow: 1;
                    flex-shrink: 1;
                }
                body > .flex-container > .d {
                    width: 150px;
                    /* height: 150px; */
                    background-color: rgb(140, 0, 255);
                   
                }

               



            </style>
    </head>
    <body>
        <div class="flex-container">
            <div class="s"></div>
            <div class="r"></div>
            <div class="d"></div>
        </div>
    </body>
</html>
728x90
반응형

'정보 > WEB' 카테고리의 다른 글

margin(외부여백)  (0) 2022.12.24
font(폰트 설정과 외부 폰트 적용)  (0) 2022.12.24
filter(이미지나 요소에 효과주기)  (0) 2022.12.24
display(표시 설정)  (0) 2022.12.24
cursor(커서모양)  (0) 2022.12.24

+ Recent posts

728x90
반응형
">