zoukankan      html  css  js  c++  java
  • [CSS3]Clearfix

    <!DOCTYPE html>
    <html>
    <head>
        <link rel="stylesheet" href="index.css" />
    </head>
    <div class="db group"> <!-- 在含有float的容器中家group class-->
        <div id="l" style="100px; height: 100px; background: red;"></div>
        <p>to left</p>
    </div>
    <div id="c">
        <div  style="100px; height: 100px; background: blue;"></div>
        <p>Not float</p>
    </div>
    </html>
    #l{
        float:left;
    }
    #c{
        border: 1px solid yellow;
    }
    .db{
        border: 1px solid aqua;
    }
    
    .group:before,
    .group:after{
        content: "";
        display: table;
    }
    .group:after{
        clear: both;
    }
    .group{
        zoom: 1;
    }

    -----------------------Ex-----------------------

    <!doctype html>
    <html lang="en">
      <head>
        <title>Sven's Snowshoe Emporium</title>
        <link rel="stylesheet" href="style.css" />
      </head>
      <body>
        <nav>
          <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact</a></li>
          </ul>
        </nav>
        <section class="content home group">
          <aside>
            <p>Did you know that Sven's Snowshoe Emporium produces the highest quality snowshoes in North America? <a href="#">Find out more</a>.</p>
          </aside>
          <article>
            <h3>New Fall Styles</h3>
            <p>Be the first at your resort to sport the hot new tennis-themed snow kicks, now available in the <a href="#">store</a>.</p>
          </article>
        </section>
      </body>
    </html>
    nav li {
      float: left;
    }
    aside {
      float: right;
      width: 120px;
    }
    article {
      float: left;
      width: 120px;
    }
    
    /* clearfix */
      
    .group:before,
    .group:after {
      content: "";
      display: table;
    }
    .group:after {
      clear: both;
    }
    .group {
      zoom: 1;
    }
  • 相关阅读:
    python之网络编程
    python之面相对象进阶
    python之面相对象程序设计
    运行期优化
    切勿用普通的for循环遍历LinkedList
    NIO网络编程
    虚拟机字节码执行引擎
    AIO(异步IO)
    选择器(Selector)
    通道(Channel)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/3898503.html
Copyright © 2011-2022 走看看