๐Ÿ’œ HTML,CSS

HTML&CSS 16์ผ์ฐจ (์ •๋ฆฌx)

Genie_. 2024. 3. 23. 22:07
728x90
๋ฐ˜์‘ํ˜•
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>๊ฐ€์ƒ์„ ํƒ์ž(์ค‘์š”!!)</title>

</head>
<style>
    section{
        width: 500px;
        height: 500px;
        background-color: #c8e5ff;
    }
    /* section"์ด๋ฉด์„œ" ์ฒซ๋ฒˆ์งธ ์ž์‹์ธ ๊ฒƒ */
    section:first-child{
        background-color: #d4ffca;
    }
    /* section"์ด๋ฉด์„œ" ๋งˆ์ง€๋ง‰ ์ž์‹์ธ ๊ฒƒ */
    section:last-child{
        background-color: #d4ffca;
    }
    li:nth-child(odd){ /* even: ์ง์ˆ˜ odd: ํ™€์ˆ˜ */
        color: red;
    }

    li:nth-child(2){ /* ๋‘๋ฒˆ์งธ์ž์‹์€ span์ด๋ฏ€๋กœ ํ•ด๋‹นํ•˜๋Š”๊ฒƒ ์—†์Œ */
        color: blue;
    }

    /* li์ธ๋ฐ ์ฒซ๋ฒˆ์งธ ์ž์‹์ด ์•„๋‹Œ li */
    li:not(:first-child){
        background-color: #ffd6de;
    }
    li:first-child::after {
        /*
        before: ์•ž์— ๋‚ด์šฉ์ถ”๊ฐ€/ after: ๋’ค์— ๋‚ด์šฉ์ถ”๊ฐ€
        ๋‹จ์  : ๊ฒฐ๊ณผ์ฐฝ์—์„œ ๋“œ๋ž˜๊ทธ ์•ˆ๋จ, ์›น์‚ฌ์ดํŠธ์—์„œ f12ํ–ˆ์„๋•Œ ๋‚ด์šฉ์ด ๋‚˜์˜ค์ง€์•Š์Œ
        */
        content: "NEW!!";
        background-color: red;
        color: white;
        font-weight: bold;
        border-radius: 2px;
        margin: 0 10px;
        padding: 0 10px;
    }

</style>
<body>
<!-- ๊ฐ€์ƒํด๋ž˜์Šค๋Š” ์ž์‹ ์„ ํƒ์€ ์žˆ์–ด๋„ ๋ถ€๋ชจ ์„ ํƒํ•˜๋ผ๋Š”๊ฑด ์—†์Œ(= ๊ฑฐ๊พธ๋กœ ๊ฑฐ์Šฌ๋Ÿฌ ์˜ฌ๋ผ๊ฐˆ ์ˆ˜ ์—†์Œ) -->
    <div>
        <ul>
            <li>1</li>
            <span>23</span>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
            <li>8</li>
        </ul>
    </div>

    <main>
        <section>SECT1</section>
        <section>SECT2</section>
        <section>SECT3</section>
    </main>

</body>
</html>

728x90
๋ฐ˜์‘ํ˜•