Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <!--  理解 BFC 作用:
  - A:阻止垂直外边距折叠
  - B:BFC 不会重叠浮动元素
  - C:可以清除浮动 -->
<h4>理解 BFC 作用</h4>
<p>A:通过给 div 添加 BFC 阻止垂直外边距折叠</p>
<div class="a"> 
  <p> a</p>
  <p> a</p>
</div>

<div class="mar-100"></div>

<div class="A"> 
  <p> A</p>
  <div><p> A</p></div>
</div>

<p>B:BFC 不会重叠浮动元素</p>
<div class="b">
  <div class="left">我是一个左浮动的元素</div>
  <div class="right">Quisque mollis tempor dolor sit amet tincidunt. Morbi ut augue blandit, interdum ex vel, tempus augue. Phasellus rutrum vehicula lorem, ullamcorper porttitor mauris iaculis ut. Praesent tincidunt lectus nisl, sed facilisis nunc volutpat non. Sed velit tortor, euismod in mi quis, faucibus finibus justo. </div>
</div>

<div class="mar-100"></div>

<div class="B">
  <div class="left">我是一个左浮动的元素</div>
  <div class="right">Quisque mollis tempor dolor sit amet tincidunt. Morbi ut augue blandit, interdum ex vel, tempus augue. Phasellus rutrum vehicula lorem, ullamcorper porttitor mauris iaculis ut. Praesent tincidunt lectus nisl, sed facilisis nunc volutpat non. Sed velit tortor, euismod in mi quis, faucibus finibus justo. </div>
</div>

<p>C:可以清除浮动</p>
<div class="c">
  <div class="left">我是一个左浮动的元素</div>
  <div class="right">Quisque mollis tempor dolor sit amet tincidunt. </div>
</div>

<div class="mar-100"></div>

<div class="C">
  <div class="left">我是一个左浮动的元素</div>
  <div class="right">Quisque mollis tempor dolor sit amet tincidunt. </div>
</div>
              
            
!

CSS

              
                .a {
  p {
    width: 100px;
    height: 100px;
    background: pink;
    margin: 50px;
  }
}

.A{
  &>div {
    overflow: hidden;
  }
  p {
    width: 100px;
    height: 100px;
    background: yellow;
    margin: 50px;
  }
}

.b {
  .left {
    height: 100px;
    width: 100px;
    float: left;
  }
  .right {
    width: 400px;
  }
}

.B {
  .left {
    height: 100px;
    width: 100px;
    float: left;
  }
  .right {
    width: 400px;
    overflow: hidden;
  }
}

.c {
  border: 5px solid green;
  .left {
    height: 100px;
    width: 100px;
    float: left;
    border: 5px solid red;
  }
  .right {
    width: 400px;
    border: 5px solid yellow;
  }
}

.C {
  border: 5px solid green;
  overflow: hidden;
  .left {
    height: 100px;
    width: 100px;
    float: left;
    border: 5px solid red;
  }
  .right {
    width: 400px;
    border: 5px solid yellow;
  }
}


.mar-100 {
  margin: 50px 0;
  border: 1px solid #eee;
}


              
            
!

JS

              
                
              
            
!
999px

Console