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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="box" id="box">
  <div class="show">
    <h2 class="show-tit">BFC演示</h2>
    <div class="show-body" id="sb">
      <!-- 添加结构单元 -->
      <div style="float: left;background-color: rgba(0,255,0,0.6);width: 150px">左浮动的测试文字</div>      
      <!-- 添加结构单元结束 -->
      <button id="reset" style="position: absolute; right:0;bottom:0">还原</button>
    </div>
    
  </div>
  <div class="con">
    <!-- 添加测试单元1 -->


  

    <dl>
      <dt>position</dt> 
      <dd>relative</dd>
      <dd>absolute</dd>
      <dd>fixed</dd>
    </dl>
    <dl>
      <dt>float</dt>  
      <dd>left</dd>
      <dd>right</dd>
      <dd>none</dd>
    </dl>
    <dl>
      <dt>display</dt>  
      <dd>block</dd>
      <dd>inline</dd>
      <dd>inline-block</dd>
      <dd>table-cell</dd>
      <dd>table-caption</dd>
      <dd>flex</dd>
    </dl>
    <dl>
      <dt>overflow</dt> 
      <dd>visible</dd>
      <dd>hidden</dd>
      <dd>scroll</dd>
      <dd>auto</dd>
    </dl>
    <!-- 添加测试单元1结束 -->

  </div>

</div>  
              
            
!

CSS

              
                body,
dl,
dd,
h2 {
  margin: 0;
}
h2 {
  font-size: 20px;
}
.box {
  overflow: hidden;
  width: 276px;
  padding: 10px;
  background-color: #ddd;
  text-align: center;
  position: relative;
  font: 18px/1.2 "宋体";
}
.con {
  float: left;
  width: 100%;
}
.show {
  float: left;
  width: 100%;
}
.show-body {
  border: 1px solid black;
  border-radius: 5px;
  padding: 5%;
  background: pink;
  position: relative;
}
#show-img {
  min-height: 20px;
  font-size: 14px;
}
.con dl * {
  float: left;
  overflow: hidden;
}
.con dl + dl {
  margin-top: 1%;
}
.con dt {
  font-weight: bold;
  width: 100%;
}
.con dd {
  background-color: rgba(255, 255, 255, 0.3);
  margin: 1%;
  cursor: pointer;
  width: 31%;
}
.con :nth-of-type(2) ~ dl dd {
  width: 48%;
}
@media (min-width: 600px) {
  .con {
    width: 50%;
  }
  .show {
    width: 50%;
  }
  .box {
    width: 580px;
  }
}
#oShow {
  border: 1px solid black;
}

              
            
!

JS

              
                function getCSS(obj,style){
    if(window.getComputedStyle){
        return getComputedStyle(obj)[style];
    }
    return obj.currentStyle[style];
};

(function con(){
  var oBox = document.getElementById('box');
  var aDl = oBox.getElementsByTagName('dl');
  var oSb = document.getElementById('sb');
  var oColor = oInset = '';
reset.onclick = function(){
  history.go();
}
  for(var i = 0, leni = aDl.length; i < leni; i++){
    var oDt = aDl[i].getElementsByTagName('dt')[0];
    var aDd = aDl[i].getElementsByTagName('dd');
    aDl[i].last = 0;

    for(var j = 0,lenj = aDd.length; j < lenj; j++){
      aDd[j].index = j;
      aDd[j].onclick = function(){
        var oDl = this.parentNode;
        var oDt = oDl.getElementsByTagName('dt')[0];
        var aDd = oDl.getElementsByTagName('dd');
        aDd[oDl.last].style.cssText = 'color: black; background-color: rgba(255,255,255,0.3);'; 
        this.style.cssText = 'color: white; background-color: black;';

        oSb.style[oDt.innerHTML] = this.innerHTML;
      
        
        oDl.last = this.index;
      }
    }
  } 
})();
              
            
!
999px

Console