๐Ÿ’œ HTML,CSS

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

Genie_. 2024. 3. 23. 21:58
728x90
๋ฐ˜์‘ํ˜•
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>๋””์Šคํ”Œ๋ ˆ์ด(์ค‘์š”)</title>
</head>
<style>
    /*
        inline : ์ธ๋ผ์ธ ์†์„ฑ์œผ๋กœ ๋œ๋‹ค.
                => ์•ˆ์— ์žˆ๋Š” ์š”์†Œ๋งŒํผ๋งŒ ํฌ๊ธฐ๋ฅผ ์ฐจ์ง€ํ•ด์„œ width, height ์•ˆ๋œ๋‹ค
        block : block ์†์„ฑ์œผ๋กœ ๋œ๋‹ค.
                => ํ•œ ์ค„์„ ์ „๋ถ€ ์ฐจ์ง€ํ•˜๋ฉฐ, width, height ๊ฐ€๋Šฅํ•˜๋‹ค.
                => width/height ์„ค์ •ํ•˜๋ฉด ์„ค์ •๋œ ๋Œ€๋กœ ๋˜๊ณ , ํ•œ์ค„ ์ „๋ถ€ ์ฐจ์ง€ํ•œ๋‹ค.
        inline-block : inline ์„ฑ๊ฒฉ๋„ ์žˆ๋Š” block์š”์†Œ
                => ํ•œ ์ค„์„ ์ „๋ถ€ ์ฐจ์ง€ํ•˜์ง€๋Š” ์•Š๋Š”๋‹ค. ๊ทผ๋ฐ block์— ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š”๊ฑฐ ์ „๋ถ€ ๊ฐ€๋Šฅํ•˜๋‹ค.
                => width/height ์„ค์ •ํ•˜๋ฉด ์„ค์ •๋œ ๋Œ€๋กœ ๋˜๋Š”๋ฐ, ๊ทธ ๋ถ€๋ถ„๋งŒ ์ฐจ์ง€ํ•ด์„œ ์˜†์— ๋‹ค๋ฅธ ์š”์†Œ๊ฐ€ ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.
        width/height ๋Š” ์ตœ๋Œ€ํ•œ ์•ˆํ•˜๋Š”๊ฒŒ ์ข‹์Œ ! padding์ด๋ž‘ margin์„ ์ตœ๋Œ€ํ•œ ์ดํ•ด
        none: ํ‘œ์‹œ์•ˆํ•จ. ์˜์—ญ์„ ์ฐจ์ง€ํ•˜์ง€ ์•Š์Œ
     */
    button{
        display: block; /* ๋ธ”๋กํ˜•์‹์œผ๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Œ */
    }
    div{
        display: inline; /* ์ธ๋ผ์ธ ํ˜•์‹์œผ๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Œ */
    }
    section {
        /*
            relative: ์š”์†Œ๊ฐ€ ์›๋ž˜ ์žˆ์—ˆ๋˜ ์œ„์น˜๊ฐ€ ๊ธฐ์ค€์ด ๋œ๋‹ค.
            absolute: ์š”์†Œ์˜ ๋ถ€๋ชจ ์œ„์น˜๊ฐ€ ๊ธฐ์ค€์ด ๋œ๋‹ค. ๊ทผ๋ฐ ๊ทธ ๋ถ€๋ชจ์˜ ํŒ๋‹จ์€,
                    ๋ถ€๋ชจ ์ค‘ position ์†์„ฑ์ด ์žˆ๋Š” ๋ถ€๋ชจ๊ฐ€ ๊ธฐ์ค€์ด ๋œ๋‹ค.
         */
        width: 100px;
        height: 100px;
        background-color: #3a7c3a;
        border: 1px solid black;
        color: white;
        box-sizing: border-box;
    }
    #box1{
        left: 10px; /* ๋งจ ์™ผ์ชฝ์—์„œ 10px ๋„์šด ์œ„์น˜๋กœ ๊ฐ€๋ผ */
    }
    #box2{
        position: relative;
        /*top: 10px;*/
        left: 20px;
        bottom: 20px;
    }
    #box3{
        position: absolute;
        right: 0;
        /*left: 30px;*/
        /*top: 0;*/
    }
</style>
<body>
    <section id="box1"></section>

    <article>
        <section id="box2">
            <section id="box3">BOX3</section>
        </section>
    </article>

    <div>DIV1</div>
    <div>DIV2</div>

    <button>๋ฒ„ํŠผ1</button>
    <button>๋ฒ„ํŠผ2</button>
    <div>DIV2</div>

</body>
</html>

728x90
๋ฐ˜์‘ํ˜•