Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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 id="panel">
  <div id="panel-inner">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Harum molestiae necessitatibus dignissimos, fuga quod eveniet adipisci sed quam asperiores corrupti suscipit, vero nostrum et inventore nulla iusto voluptate accusamus iure modi eius ab? Hic illo rem tenetur dolore corporis a architecto dolorem reprehenderit ipsum harum quaerat, alias ex officia beatae maxime accusantium eius.
    <a class="panel-close"><svg class="icon-line_x"><use xlink:href="#icon-line_x"></use></svg></a>
    <footer>
      <button class="border-radius-left">Button 1</button>
      <button class="border-radius-right">Button 2</button>
    </footer>
  </div>
</div>

<svg style="position: absolute; width: 0; height: 0;" width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-line_x" viewBox="0 0 1024 1024">
	<title>line_x</title>
	<path class="path1" d="M265.376 758.624c6.256 6.256 14.432 9.376 22.624 9.376s16.368-3.12 22.624-9.376l201.376-201.376 201.376 201.376c6.256 6.256 14.432 9.376 22.624 9.376s16.368-3.12 22.624-9.376c12.496-12.496 12.496-32.752 0-45.248l-201.376-201.376 201.376-201.376c12.496-12.496 12.496-32.752 0-45.248s-32.752-12.496-45.248 0l-201.376 201.376-201.376-201.376c-12.496-12.496-32.752-12.496-45.248 0s-12.496 32.752 0 45.248l201.376 201.376-201.376 201.376c-12.496 12.496-12.496 32.752 0 45.248z"></path>
</symbol>
</defs>
</svg>
              
            
!

CSS

              
                @import compass

body
  margin: 4em
  background: #f7f7f7
  font-family: Lato
  font-weight: 300
  line-height: 1.4em
  
a, button
  transition: all .2s ease-out
  cursor: pointer

[class^="icon-"], [class*=" icon-"]
  display: inline-block
  width: 1em
  height: 1em
  fill: currentColor
  
#panel
  position: absolute
  width: 500px
  height: auto
  top: 50%
  left: 50%
  perspective: 1000px
  
  @include transition( all .15s ease-out )
  @include transform( translate(-50%, -50%) rotateY(0deg) rotateX(0deg) rotateZ(0deg) )
    
  #panel-inner
    background: #fff
    box-shadow: 0 20px 100px rgba(0,0,0,.2)
    padding: 3em
    border-radius: 16px
    
    .panel-close
      display: block
      position: absolute
      top: 0
      right: 0
      width: 3em
      line-height: 3em
      text-align: center
      border-radius: 0 16px 0 16px
      color: #aaa
      
      svg
        pointer-events: none
      
      &:hover
        background: #f7f7f7
        
  footer
    margin: 2.5em -3em -3em -3em
    overflow: hidden
    
    button
      display: block
      width: 50%
      padding: 1.5em 1em
      float: left
      background: #fff
      border: none
      border-top: 1px solid #eee
      color: #888
      outline: none
      
      &.border-radius-left
        border-radius: 0 0 0 16px
        
      &.border-radius-right
        border-radius: 0 0 16px 0
      
      &:hover
        background: #eee
              
            
!

JS

              
                var $panel = $('#panel-inner');
var maxY = 20,
    maxX = 20,
    maxZ = 2;

$panel.mousemove( function(e){
  var $this = $(this);
  e.stopImmediatePropagation();
  var offsetY = (e.target!=e.deletageTarget)? e.offsetY+e.target.offsetTop:e.offsetY;
  var offsetX = (e.target!=e.deletageTarget)? e.offsetX+e.target.offsetLeft:e.offsetX;
  var w = $panel.outerWidth(), h = $panel.outerHeight();
  var transform = { y: 1-offsetX/w*2, x: 0-(1-offsetY/h*2) };
  transform.z = 0-(transform.x * transform.y);
  
  var transformCSS = { 
    x: calculateValue(maxX, transform.x),
    y: calculateValue(maxY, transform.y), 
    z: calculateValue(maxZ, transform.z) };
  
  $this.css({
    transform:
    'rotateY('+transformCSS.y+'deg) rotateX('+transformCSS.x+'deg) rotateZ('+transformCSS.z+'deg)'
  });
});

$panel.mouseleave(function(){
  var $this = $(this);
  $this.css({
    transform:
    'rotateY(0deg) rotateX(0deg) rotateZ(0deg)',
    transition: 'all .15s ease-out'
  });
});

function calculateValue( max, value ){
  return max*value;
}
              
            
!
999px

Console