Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <div class="box" id="box">
  <div class="show">
    <h2 class="show-tit">box-sizing演示</h2>
    <div class="show-body" id="sb">
      <!-- 添加结构单元 -->
      <div id="oShow">

      <!-- 添加结构单元结束 -->
    <div id="show-img"></div>
    <button id="reset">还原</button>
  <div class="con">
    <!-- 添加测试单元1 -->



                body,dl,dd,h2{margin: 0;}
.box{overflow: hidden;width:276px;padding:10px;background-color: #ddd;text-align: center;position:relative;font:18px/1.2 "宋体";} 
.show-body{border: 1px solid black;border-radius: 5%;padding: 5%;}
#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: 48%;} 
@media (min-width:600px) {.con{width:60%;}.show{width:40%;}.box{width:580px;}}
#oShow{margin: 0 auto;width: 100px;height: 50px;border: 1px solid black;padding: 10px;background-color: pink;


                function getCSS(obj,style){
        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 oShow = document.getElementById('oShow');
  var oImg = document.getElementById('show-img');
  reset.onclick = function(){
  var aC2 = oShow.getElementsByTagName('h2');
  var aC3 = oShow.getElementsByTagName('h3');
  var aCp = oShow.getElementsByTagName('p');
  var oDc2=oDc3=oDcp = 'decimal';
  var oD = ' '; 
  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);'; = 'color: white; background-color: black;';[oDt.innerHTML] = this.innerHTML;
        oImg.innerHTML = 'width:' + getCSS(oShow,'width');
        oDl.last = this.index;