浮动和清除浮动

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cf:after {
            visibility: hidden;
            display: block;
            font-size: 0;
            content: "";
            clear: both;
            height: 0;
        }

        *.cf {
            zoom: 1;
        }

        #w {
            width: 1000px;

            border: 1px solid red;

        }

        #c {
            width: 500px;
            height: 374px;
            float: left;
            background: #e6e6e6;
            border: 1px solid red;
        }

        #t {
            width: 400px;
            float: left;
            border: 1px solid red;
            margin-left: 35px;
        }
    </style>
</head>

<body>
    <div id="w" class="cf">
        <div id="c"> zuo </div>
        <div id="t"> you </div>
    </div>

</body>

</html>

  

posted @ 2022-04-14 09:26  指针园  阅读(21)  评论(0)    收藏  举报