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操作进行相当于添加一条分界线,使板块进行理论上的分离。

  • 相关阅读:
    UIWebView stringByEvaluatingJavaScriptFromString的使用方法
    手动截图
    KVO与KVC的使用(转)
    LKDBHelper Sqlite操作数据库
    GCD多线程的使用
    ios --- 调用系统"设置"里的功能(转)
    ios开发小技巧(转)
    url字符串中含中文的转码方法
    ios 照片编辑的view封装
    字符串去空格
  • 原文地址:https://www.cnblogs.com/scw123/p/9461039.html
Copyright © 2011-2022 走看看