CSS입문

CSS_flex-box_간단한 실습_22.04.19(Tue)

양빵빵 2022. 4. 19. 17:11

 

 

<!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>
        body {
            width: 80%;
            margin: 10px auto;
            text-align: center;
        }

        .container {
            /* background: pink; */
        }

        header {
            background: red;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 50px;
        }

        section {
            display: flex;
            height: 500px;
        }

        .main {
            background: gray;
            width: 80%;
            display: flex;
            justify-content: center;
            align-items: center;

        }

        .left {
            background: yellow;
            width: 20%;
            order: -100;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .right {
            background: green;
            width: 20%;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        footer {
            background: skyblue;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 50px;
        }
    </style>

</head>

<body>
    <div class="container">
        <header>Header</header>
        <section>
            <article class="main">
                <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
                    Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit
                    amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
            </article>
            <article class="left">Aside 1</article>
            <article class="right">Aside 2</article>
        </section>
        <footer>Footer</footer>
    </div>

</body>

</html>
 
 
=============================== ↑ 실습 / 선생님 코딩↓=================
 
 

<!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 {
            background: tomato;
            width: 1200px;
            margin: 0 auto;
            display: flex;
            flex-wrap: wrap;
            text-align: center;
        }
        .container header {
            background: brown;
            flex: 1;
            padding: 1em;
        }
        .container section {
            display: flex;
        }
        .container section article {
            padding: 15em 1em;
        }
        .container section .main {
            background: gray;
            order: 2;
            flex: 4;
        }
        .container section .left {
            background: yellow;
            order: 1;
            flex: 1;
        }
        .container section .right {
            background: green;
            order: 3;
            flex: 1;
        }
        .container footer {
            background: skyblue;
            flex: 1;
            padding: 1em;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>Header</header>
        <section>
            <article class="main">
                <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
            </article>
            <article class="left">Aside 1</article>
            <article class="right">Aside 2</article>
        </section>
        <footer>Footer</footer>
    </div>
</body>
</html>