Java script

[Java script] display flex

EmilyP 2021. 4. 12. 16:36

displayflex.html
0.00MB

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

            *

        margin:0padding:0;

    }

            ulli{list-style:none;}

 

            .gnb{display:flex;

                width:300px;

                height900px;

              

                flex-directioncolumn/*column으로 바꿔주면 일자로... 높이값도 지정해주면 모바일에서도 가능 */

                flex-wrapwrap/* gnb width 600px 넘어가면 아래로 떨어뜨리겠다. nowrap은 일자로 */

                justify-contentcenter/* flex박스 안에 영역 정렬 */

            }

            .gnb > li {

                width:200px;

                height:300px;

            }

 

            .gnb > li:nth-child(1){backgroundred;}

            .gnb > li:nth-child(2){backgroundblue;}

            .gnb > li:nth-child(3){backgroundpurple;}

            .gnb > li:nth-child(4){background:pink;}

            .gnb > li:nth-child(5){background:yellow;}

            .gnb > li:nth-child(6){background:skyblue;}

            .gnb > li:nth-child(7){backgroundblack}




        </style>

</head>

<body>

    <ul class="gnb">

        <li></li>

        <li></li>

        <li></li>

        <li></li>

        <li></li>

        <li></li>

        <li></li>

        

    </ul>

</body>

</html>