CSS去浮动和margin

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .test{
            background: greenyellow;
        }
        div div{
            width: 200px;
            height: 200px;
            border: 1px red solid;
            float: left;
            margin: 20px;

        }
        .test::after,.test::before{
            content: '';
            display: table;
            clear: both
        }
        .div1{
            float: none;
        }
    </style>

<body>
    <div class="test">
            <div class="div1">div1</div>
            <div class="div2">div2</div>
            <div class="div3">div3</div>
            <div class="div4">div4</div>
            <div class="div5">div5</div>
            <div class="div6">div6</div>  
            
    </div>
      
</body>

</html>
Last modification:June 21st, 2019 at 04:15 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment