cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="block block1">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
<div class="block block2">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
<div class="block block3">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
<div class="block block4">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
<div class="block block5">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
<div class="block block6">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
<div class="block block7">
  <div class="wrap wrap1">
    <div class="sub"></div>
  </div>
  <div class="wrap wrap2">
    <div class="sub sub-bordered"></div>
  </div>
  <div class="wrap wrap3">
    <div class="sub sub-padding"></div>
  </div>
  <div class="wrap wrap4">
    <div class="sub sub-bordered sub-padding"></div>
  </div>
</div>
            
          
!
            
              .block{
  border: 2px solid green;
  padding: 10px;
  margin-bottom: 30px;
}
.log{
  padding: 10px;
}
.wrap{
  position: relative;
  width: 100px;
  height: 30px;
  margin: 20px 0;
  border: 1px solid #ccc;
  padding: 4px 6px 5px 7px;
}
.sub{
  position: absolute;
  background: #aaa;
}
/* with border */
.sub-bordered{
  border: 2px solid red;
}
/* with padding */
.sub-padding{
  padding: 5px 7px;
}
.log{
  margin-top: 30px;
  margin-bottom: 30px;
  line-height: 1.2;
  background: #888;
  color: #fff;
}
.log h3{
  margin: 5px 0;
  padding: 2px 6px;
  background: #555;
}
/* 100% width and height */
.block2 .sub,
.block3 .sub{
  width: 80%;
  height: 70%;
}
.block3 .wrap,
.block5 .wrap{
  position: static;
  width: 200px;
  height: 200px;
}
.block3,
.block5{
  position: relative;
  width: 300px;
  height: 100px;
  margin-bottom:1000px;
}
/* positioned */
.block4 .sub,
.block5 .sub{
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
.block6 .sub,
.block7 .sub{
  width: 40px;
  height: 10px;
}
.block7 .sub{
  overflow: visible;
}
            
          
!
            
              $(function(){
  $('.block').each(function(n){
    $(this).prepend('<div class="mark">.block' + (n+1) + '</div>');
    $(this).after('<div class="log" id="log' + (n+1) + '"></div>');
    var logElement = $('#log' + (n+1) );
    $(this).children('.wrap').each(function(i){
      $(this).children('.sub').append('.wrap' + (i+1) + ' .sub'  );
      logElement.append( '<h3>.block' + (n+1) + ' .wrap' + (i+1) + '</h3>');
      logElement.append( '<div class="inner">' );
      logElement.append(".wrap width: " + $(this).width() + "<br />" );
      logElement.append(".wrap height: " + $(this).height() + "<br />" );
      logElement.append(".sub width: " + $(this).children('.sub').width() + "<br />" );
      logElement.append(".sub height: " + $(this).children('.sub').height() + "<br /><br />" );
      logElement.append( '</div>' );
    });
  });
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console