zoukankan      html  css  js  c++  java
  • css中的float与clear功能

    首先进行float操作不进行clear操作,如下

    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
              <style type="text/css">
                  *{
                      margin: 0;
                      padding: 0;
                  }
                  .clear{
                      clear: both;    
                  }
                  #folat{
                      height: 100px;
                      width: 100px;
                      background-color: #00FFFF;
                      
                  }
                  ul{
                      list-style: none;
                      margin-right: 100px;
                  }
                  li{
                      width: 50px;
                      height: 30px;
                      border: 2px solid red;
                      font-family: "微软雅黑";
                      line-height: 30px;
                      text-align: center;
                      margin-left: 30px;
                      float: right;
                      
                  }
              </style>
        </head>
        <body>
            <ul>
                <li>你</li>
                <li>我</li>
                <li>他</li>
                <li>他</li>
            </ul>
            <div id="folat">
                
            </div>
        </body>
    </html>

    效果如下:

    但是在加入clear操作之后,如下:

    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
              <style type="text/css">
                  *{
                      margin: 0;
                      padding: 0;
                  }
                  .clear{
                      clear: both;    
                  }
                  #folat{
                      height: 100px;
                      width: 100px;
                      background-color: #00FFFF;
                      
                  }
                  ul{
                      list-style: none;
                      margin-right: 100px;
                  }
                  li{
                      width: 50px;
                      height: 30px;
                      border: 2px solid red;
                      font-family: "微软雅黑";
                      line-height: 30px;
                      text-align: center;
                      margin-left: 30px;
                      float: right;
                      
                  }
              </style>
        </head>
        <body>
            <ul>
                <li>你</li>
                <li>我</li>
                <li>他</li>
                <li>他</li>
            </ul>
            <div class="clear"></div>
            <div id="folat">
                
            </div>
        </body>
    </html>

     效果如下:

     clear操作进行相当于添加一条分界线,使板块进行理论上的分离。

  • 相关阅读:
    【转】使用Eclipse的几个必须掌握的快捷方式
    【原创】远景能源面试--一面
    vritualenv虚拟环境迁移
    Mysql数据库的增删改查
    Java面向对象的三大特征
    JAVA 数组
    JAVA简介
    web前端瀑布流设计分析
    华为C语言编程规范
    学生成绩管理系统1.0v 完成的学习总结
  • 原文地址:https://www.cnblogs.com/scw123/p/9461039.html
Copyright © 2011-2022 走看看