css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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. 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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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>
            
          
!
            
              @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
            
          
!
            
              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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console