Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- frrom------[那些年我们一起清除过的浮动][http://www.iyunlu.com/view/css-xhtml/those-years-we-have-cleared-with-floats.html] -->
<body>
  <div class="content">
    <h2>闭合浮动 与  清除浮动 的区别</h2>
    <div class="wrap">wrap
      <div class="main left">.main:很抱歉,现代浏览器中我没能把wrap撑高(float:left)</div>
      <div class="side left">.side:我也浮动了(float:left)</div>
    </div>
    <div class="footer clear">.footer:我通过设置 clear:both <strong>清除浮动</strong>,虽然位置正确了,但是 wrap 的高度没变,有些不爽</div>
    <div class="wrap clearfix" id="floa7"><strong>wrap</strong>
      <div class="main left">.main:wrap自己闭合浮动了,所以footer不用再清除浮动了(float:left)</div>
      <div class="side left">.side:我也浮动了(float:left)</div>
    </div>
    <div class="footer">.footer:这次 wrap 人品爆发了, 通过 .clearfix 已经<strong>闭合浮动</strong>了</div>
    <h2>闭合浮动的几种方法</h2>
    <div class="wrap" id="float1">
      <h3>1)添加额外标签: &lt;div style="clear:both;"&gt;&lt;&frasl;div&gt;</h3>
      <div class="main left">.main{float:left;}</div>
      <div class="side left">.side{float:right;}</div>
      <div style="clear:both;"></div>
    </div>
    <div class="footer">.footer</div>
    <div class="wrap" id="float2">
      <h3>2)使用 br标签和其自身的 html属性:&lt;br clear="all" &frasl;&gt;</h3>
      <div class="main left">.main{float:left;}</div>
      <div class="side left">.side{float:right;}</div>
      <br clear="all" />
    </div>
    <div class="footer">.footer</div>
    <div class="wrap" id="float3" style="overflow:hidden; *zoom:1;">
      <h3>3)父元素设置 overflow:hidden</h3>
      <div class="main left">.main{float:left;}</div>
      <div class="side left">.side{float:right;}</div>
    </div>
    <div class="footer">.footer</div>
    <div class="wrap" id="float6" style="display:table;">
      <h3>6)父元素设置display:table</h3>
      <div class="main left">.main{float:left;}</div>
      <div class="side left">.side{float:right;}</div>
    </div>
    <div class="footer">.footer</div>
  </div>
</body>

              
            
!

CSS

              
                  * {
    margin: 0;
    padding: 0;
  }
  
  a {
    text-decoration: none;
    color: #333;
  }
  
  h1 {
    font-size: 22px;
    margin-top: 10px;
    padding: 10px 0;
    text-align: center;
  }
  
  h2 {
    font-size: 16px;
    margin: 20px 0;
    text-align: center;
    color: #555;
  }
  
  h3 {
    font-size: 14px;
    color: #666;
    padding: 10px 0;
  }
  
  .clearfix:after {
    clear: both;
    content: ".";
    display: block;
    height: 0;
    visibility: hidden;
  }
  
  .clearfix {
    *zoom: 1;
  }
  
  .clear {
    clear: both;
  }
  
  .left {
    float: left;
  }
  
  .right {
    float: right;
  }
  
  .left,
  .right {
    *display: inline;
  }
  
  div {
    padding: 15px 20px;
    font-size: 14px;
    color: #333;
  }
  
  .content {
    padding-bottom: 200px;
  }
  
  .wrap {
    border: 1px solid blue;
    width: 600px;
    margin: 30px auto 5px;
    background: #F5F5F5;
  }
  
  .main {
    height: 60px;
    width: 50%;
    background: #FFE3D7;
  }
  
  .side {
    width: 20%;
    background: lightblue;
  }
  
  .footer {
    border: 1px solid #CCC;
    background: #EEE;
    width: 600px;
    margin: 5px auto 30px;
  }
              
            
!

JS

              
                
              
            
!
999px

Console