Task 1

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Float: Task 1</title>
    <style>
        body {
            background-color: #fff;
            color: #333;
            font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
            padding: 1em;
            margin: 0;
        }

        * {
            box-sizing: border-box;
        }

        .box {
            width: 500px;
            padding: 0.5em;
        }

        .float {
            margin: 15px;
            width: 150px;
            height: 150px;
            border-radius: 5px;
            background-color: rebeccapurple;
            color: #fff;
            padding: 1em;
        }

        .float1 {
            float: left;
        }

        .float2 {
            float: right;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="float float1">One</div>
        <div class="float float2">Two</div>
        <p>The two boxes should float to either side of this text.</p>
    </div>
</body>
</html>

 

Task 2

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Float: Task 2</title>
    <style>
        body {
            background-color: #fff;
            color: #333;
            font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
            padding: 1em;
            margin: 0;
        }

        * {
            box-sizing: border-box;
        }

        .box {
            width: 500px;
            padding: 0.5em;
        }

        .float {
            margin: 15px;
            width: 150px;
            height: 150px;
            border-radius: 5px;
            background-color: rebeccapurple;
            color: #fff;
            padding: 1em;
        }

        .float {
            float: left;
        }

        .below {
            clear: left;
            
        }
    </style>
</head>

<body>

    <div class="box">
        <div class="float">Float</div>
        <p>This sentence appears next to the float.</p>
        <p class="below">Cause this sentence to appear below the float.</p>
    </div>
</body>
</html>

 

 

Task 3

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Float: Task 3</title>
    <link rel="stylesheet" href="../styles.css" />
    <style>
        body {
            background-color: #fff;
            color: #333;
            font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
            padding: 1em;
            margin: 0;
        }

        * {
            box-sizing: border-box;
        }

        .box {
            width: 500px;
            padding: 0.5em;
        }

        .float {
            margin: 15px;
            width: 150px;
            height: 150px;
            border-radius: 5px;
            background-color: rgb(207, 232, 220);
            padding: 1em;
            float: right;
        }

        .box {
            background-color: rebeccapurple;
            padding: 10px;
            color: #fff;
            display: flow-root;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="float">Float</div>
        <p>This sentence appears next to the float.</p>
    </div>
</body>
</html>

 

도움 받은 곳

https://github.com/mdn/css-examples/blob/main/learn/tasks/float/marking.md

 

 

'CSS > MDN 문제 풀이' 카테고리의 다른 글

Test your skills: Multicol  (0) 2022.11.17
Test your skills: Positioning  (0) 2022.11.15
Test your skills: Grid  (0) 2022.11.15
Test your skills: Flexbox  (0) 2022.11.14
Test your skills: Tables  (0) 2022.11.09

+ Recent posts