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 class="one">HOVER</div>
              
            
!

CSS

              
                	*, *:before, *:after {
  -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
 }	
body{
			-webkit-transform: translate3d(0,0,0);
			-moz-transform: translate3d(0,0,0);
			-mstransform: translate3d(0,0,0);
			-o-transform: translate3d(0,0,0);
			transform: translate3d(0,0,0);
			-webkit-perspective: 50px;
			-moz-perspective: 50px;
			-ms-perspective: 50px;
			-o-perspective: 50px;
			perspective: 50px;
		}
		.one{
  height: 100px;
  width: 100px;
  position: relative;
  top: 50%;
  left: 50%;
  margin-left:-50px;
  background-color: red;
  text-align:center;
  color:white;
  font-family:helvetica;
  padding-top:4%;
		}
              
            
!

JS

              
                $(function(){
  
  function swing(target) {
      // the values in vars can (and should) be tweaked to modify the way the swing works
      // * = affected by power
      var vars = {
          origin: 'bottom right',   // transformOrigin
          perspective: 50,       // transformPerspective
          ease: Linear.easeNone, // an easeInOut should really be used here...
          power: .8,               // multiplier for the effect that is reduced to 0 over the duration
          duration: 5,            // total length of the effect (well, it can be up to vars.speed longer than this)
          skewX: -25,          // start rotation, also stores target rotations during tween
          maxSkew: 25,        // * max rotation after starting
          speed: 0.02,             // minimum duration for each swing
          maxspeed: 0.03          // * extra duration to add to the larger swings (any sort of real physics seems like overkill)
      };
      
      // target could be a string selector (it will be selected each swing though...), or a DOM or jQuery object
      vars.target = target;
      
      // starting position
      TweenMax.set(vars.target, { skewX: 0, transformOrigin: vars.origin, transformPerspective: vars.perspective, ease:Expo.easeOut });
      
      TweenMax.to(vars, vars.duration, { power: 0, onStart: nextSwing, onStartParams: [vars] });
  }
  
  function nextSwing(vars) {
    if (vars.power > 0) {
      //console.log(vars);
      vars.skewX = (vars.skewX > 0 ? -1 : 1) * vars.maxSkew * vars.power;
      TweenMax.to(vars.target, vars.speed + vars.maxspeed * vars.power, { skewX: vars.skewX, ease: vars.ease, onComplete: nextSwing, onCompleteParams: [vars] });
    } else {
      TweenMax.to(vars.target, vars.speed, { skewX: 0, ease: vars.ease });
    }
  }
   
  $(".one").mouseenter(function(){
    swing('.one');
  });

});
              
            
!
999px

Console