๐Ÿ’œ HTML,CSS

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

Genie_. 2024. 3. 23. 22:11
728x90
๋ฐ˜์‘ํ˜•
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>float</title>
</head>
<style>
    div {
        padding: 20px;
    }
    #box1{
        /* float๋Š” ์ž์‹ ์ด ๊ฐ€์ง€๋Š” ํฌ๊ธฐ๋งŒํผ ํ•ด๋‹น ๋ฐฉํ–ฅ์œผ๋กœ ๋ถ™์ด๋Š” ๊ฒƒ */
        background-color: cadetblue;
        float: left; /* ์™ผ์ชฝ์œผ๋กœ ํ”Œ๋กœํŒ… */
    }
    #box2{
        background-color: cornflowerblue;
        float: right;
    }
    #box3{
        background-color: bisque;
        float: right;
    }
    #box4{
        background-color: darkseagreen;
        float: right;
        /* clear๋ฅผ ์•ˆํ•˜๋ฉด float์š”์†Œ์—๊ฒŒ ๋ถ™์œผ๋ฉด์„œ ๋‚จ๋Š” ๊ณต๊ฐ„ ์ฐจ์ง€ํ•จ */
        /* clear: both; */
    }
    span{
        vertical-align: bottom;
        clear: left; /* float: left ๋˜์–ด์žˆ๋Š” ๊ฒƒ์„ ํ•ด์ œํ•ด๋ผ */
    }

</style>
<body>
    <div id="box1">๋ฐ•์Šค1</div>
    <div id="box2">๋ฐ•์Šค2</div>
    <div id="box3">๋ฐ•์Šค3</div>
    <div id="box4">๋ฐ•์Šค4</div>


    <section>
        <img src="cat.jpg" alt="">
        <span>ํ•˜์ด์šฉ</span>
    </section>

</body>
</html>

728x90
๋ฐ˜์‘ํ˜•