zoukankan      html  css  js  c++  java
  • 2019.12.04-清除浮动代码

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>清除浮动</title>
    </head>
    <style type="text/css">
    .con,.con2{
    300px;
    border:1px solid #000;
    margin: 100px auto 0;
    font-size: 0;

    }

    .con a{
    50px;
    height: 50px;
    display:inline-block;
    background-color: gold;
    font-size: 16px;
    margin: 10px;
    text-align: center;
    line-height: 50px;
    text-decoration: none;
    }

    /* 第一种清除浮动
    .con2{
    overflow: hidden;
    }
    */

    .con2 a{
    50px;
    height: 50px;
    background-color: gold;
    font-size: 16px;
    margin: 10px;
    text-align: center;
    line-height: 50px;
    text-decoration: none;
    float: left;
    }

    /*
    .clearfix:before{
    content: "";
    display: table;
    }


    .clearfix:after{
    content: "";
    display: table;
    clear: both;
    }
    */
    .clearfix:before,.clearfix:after{
    content: "";
    display: table;
    }

    .clearfix:after{
    clear: both;
    }

    .clearfix{
    zoom:1;
    }

    .con3{
    300px;
    border:1px solid #000;
    margin: 100px auto 0;
    }

    .con3 span{
    background-color: gold;
    float: left;
    }

    </style>
    <body style="height: 2000px;">

    <div class="con">
    <a href="#">1</a>
    <a href="#">2</a>
    <a href="#">3</a>
    <a href="#">4</a>
    <a href="#">5</a>
    <a href="#">6</a>
    <a href="#">7</a>
    <a href="#">8</a>
    <a href="#">1</a>
    <a href="#">2</a>
    <a href="#">3</a>
    <a href="#">4</a>
    </div>

    <div class="con2 clearfix">
    <a href="#">1</a>
    <a href="#">2</a>
    <a href="#">3</a>
    <a href="#">4</a>
    <a href="#">5</a>
    <a href="#">6</a>
    <a href="#">7</a>
    <a href="#">8</a>
    <a href="#">1</a>
    <a href="#">2</a>
    <a href="#">3</a>
    <a href="#">4</a>
    <!-- <div style="clear: both"></div> 清楚浮动的第二种方法,不推荐 -->
    </div>

    <div class="con3 clearfix">
    <span>span元素</span>
    <span>span元素</span>
    <span>span元素</span>
    <span>span元素</span>
    <span>span元素</span>
    </div>

    </body>
    </html>

  • 相关阅读:
    Linux删除文件相关命令
    Bing语句
    VS2013配置Winpcap
    node10-mongoose
    node09-cookie
    node08-express
    node07-http
    node06-path
    node05-fs
    node04-buffer
  • 原文地址:https://www.cnblogs.com/lishuide/p/11985969.html
Copyright © 2011-2022 走看看