h5新增标签demo【+清空浮动】

发布时间 2023-12-02 15:53:15作者: __username

直接上代码

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 清除浮动写法 */
        .clearfix::before,
        .clearfix::after {
            content: "";
            display: table;
        }

        .clearfix::after {
            clear: both;
        }

        .clearfix {
            overflow: hidden;
        }

        .warp {
            width: 1000px;
            margin: 0 auto;
        }

        header {
            height: 150px;
            border: 1px solid #000;
        }

        nav {
            height: 40px;
            border: 1px solid #000;
        }

        /* section {
            height: 1000px;
            border: 1px solid #000;
        } */

        aside {
            width: 200px;
            height: 300px;
            float: left;
            border: 1px solid #000;
        }

        article {
            width: 780px;
            height: 980px;
            float: right;
            border: 1px solid #000;
        }

        footer {
            height: 60px;
            border: 1px solid #000;
        }
    </style>
</head>

<body>
    <header class="warp">
        头部
    </header>
    <nav class="warp">
        导航
    </nav>
    <section class="warp clearfix">
        <aside>侧边栏</aside>
        <article>
            <h1>文章标题</h1>
            <p>文章段落1</p>
            <p>文章段落2</p>
            <p>文章段落3</p>
        </article>
    </section>
    <footer class="warp">
        尾部
    </footer>
</body>

</html>

效果图