cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-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="box">
  <div class="wrapper"><a class="target" href="#">Target</a></div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam, perferendis. Incidunt deserunt temporibus, tempore et, possimus fuga quod dolore, excepturi quia magnam quidem. Nobis, dolores dignissimos 
</div>
<div class="log-a">浏览器计算的尺寸:</div>
<div class="log-b">用getBoundingClientRect()获取的尺寸:</div>
            
          
!
            
              .box {
  width: 200px;
  height: 200px;
  border: 1px solid #ccc;
  background: #eee; 
  margin-bottom: 20px;
}
.target {
  float: left; 
  width: 50px;
  height: 50px;
  line-height: 50px;
  font-size: 12px;
  text-align: center;
  transform-origin: 0 center;
  transform: scale(.7) translateX(40px);
  opacity:.8;
  background: #333;
  color: #fff;
}
.wrapper {
  float:left;
  background:red;
}
            
          
!
            
              $(function(){
  // get the actual size  
  var calculatedRect = $('.target')[0].getBoundingClientRect();
  $('.log-a').append('width:' + $('.target').width() + ',height:' + $('.target').height());
  $('.log-b').append('width:' + calculatedRect.width + ',height:' + calculatedRect.height);
});
            
          
!
999px
Loading ..................

Console