Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

Behavior

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.

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                %header
  .container
    %h1 Direction-aware hover effect
    %p CSS &amp; bits of JS
.container
  %ul
    - 12.times do
      %li
        %a{:href => "#", :class => "normal"}
          %svg{:viewBox => "0 0 80 76", :x => "0px", :y => "0px"}
            %g
              %path{:d => "M 68.9708 24.8623 L 60.4554 2.3018 C 59.9641 0.7017 58.1628 -0.2583 56.5252 0.3817 L 1.9822 20.2222 C 0.3822 20.7022 -0.4179 22.6222 0.2222 24.2223 L 8.8624 47.7797 L 8.8624 35.1484 C 8.8624 29.5024 13.3425 24.8623 18.8857 24.8623 L 32.9442 24.8623 L 50.63 12.862 L 60.7829 24.8623 L 68.9708 24.8623 L 68.9708 24.8623 ZM 77.098 32.0625 L 18.8857 32.0625 C 17.2512 32.0625 16.0625 33.4511 16.0625 35.1484 L 16.0625 72.8491 C 16.0625 74.5477 17.2512 75.9375 18.8857 75.9375 L 77.098 75.9375 C 78.742 75.9375 79.9376 74.5477 79.9376 72.8491 L 79.9376 35.1484 C 79.9376 33.4511 78.742 32.0625 77.098 32.0625 L 77.098 32.0625 ZM 73.0626 68.0625 L 23.9375 68.0625 L 23.9375 61.0852 L 31.4704 43.7232 L 42.7696 57.6777 L 53.4138 46.8062 L 67.1695 41.9375 L 73.0626 55.0815 L 73.0626 68.0625 L 73.0626 68.0625 Z"}
        .info
          %h3 Single-origin coffee whatever
          %p Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.
              
            
!

CSS

              
                @import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Bree+Serif);

$w: 200;
$h: 180;
$duration: 300ms;
$timing-fn: ease;

$turquoise: #1ABC9C;
$wet-asphalt: #34495E;
$midnight-blue: #2C3E50;
$clouds: #ECF0F1;

* {box-sizing: border-box}

body {background-color: #fff}

h1 {
  margin: 0 auto 5px;
  text-align: center;
}

h3 {font-family: 'Bree Serif', serif}

.container {
  width: 840px;
  margin: 0 auto;
}

header {
  font-family: 'Bree Serif', serif;
  text-align: center;
  margin: 50px 0 25px;
  color: $wet-asphalt;
  p {
    margin: 0;
    color: transparentize($wet-asphalt, .6);
  }
}

ul {
  padding: 0;
  margin: 0 0 50px;
  &:after {
    content: ".";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
  }
}

li {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  list-style: none;
  float: left;
  width: #{$w}px;
  height: #{$h}px;
  margin: 5px;
  padding: 0;
  perspective: 500px;
  a  {
    display: inline-block;
    vertical-align: top;
    text-decoration: none;
    border-radius: 4px;
  }
  h3 {
    margin: 0;
    font-size: 16px;
    color: transparentize(#fff, .1);
  }
  p  {
    font-size: 12px;
    line-height: 1.5;
    color: transparentize(#fff, .2);
  }
  .normal {
    width: 100%;
    height: 100%;
    background-color: $clouds;
    color: transparentize($wet-asphalt, .4);
    box-shadow: inset 0 2px 20px darken($clouds, 2);
    text-align: center;
    font-size: 50px;
    line-height: #{$h}px;
    svg {
      pointer-events: none;
      width: 50px;
      path {
        fill: transparentize($wet-asphalt, .8);
      }
    }
  }
  .info {
    width: 100%;
    height: 100%;
    padding: 20px;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    border-radius: 4px;
    pointer-events: none;
    background-color: transparentize($turquoise, .1);
    transform: rotate3d(1, 0, 0, 90deg);
  }
}

.in-top .info {
   transform-origin: 50% 0%;
   animation: in-top $duration $timing-fn 0ms 1 forwards;
}
.in-right .info {
  transform-origin: 100% 0%;
  animation: in-right $duration $timing-fn 0ms 1 forwards;
}
.in-bottom .info {
  transform-origin: 50% 100%;
  animation: in-bottom $duration $timing-fn 0ms 1 forwards;
}
.in-left .info {
  transform-origin: 0% 0%;
  animation: in-left $duration $timing-fn 0ms 1 forwards;
}

.out-top .info {
  transform-origin: 50% 0%;
  animation: out-top $duration $timing-fn 0ms 1 forwards;
}
.out-right .info {
  transform-origin: 100% 50%;
  animation: out-right $duration $timing-fn 0ms 1 forwards;
}
.out-bottom .info {
  transform-origin: 50% 100%;
  animation: out-bottom $duration $timing-fn 0ms 1 forwards;
}
.out-left .info {
  transform-origin: 0% 0%;
  animation: out-left $duration $timing-fn 0ms 1 forwards;
}

@keyframes in-top {
  from {transform: rotate3d(-1, 0, 0, 90deg);}
  to   {transform: rotate3d(0, 0, 0, 0deg);}}
@keyframes in-right {
  from {transform: rotate3d(0, -1, 0, 90deg);}
  to   {transform: rotate3d(0, 0, 0, 0deg);}}
@keyframes in-bottom {
  from {transform: rotate3d(1, 0, 0, 90deg);}
  to   {transform: rotate3d(0, 0, 0, 0deg);}}
@keyframes in-left {
  from {transform: rotate3d(0, 1, 0, 90deg);}
  to   {transform: rotate3d(0, 0, 0, 0deg);}}

@keyframes out-top {
  from {transform: rotate3d(0, 0, 0, 0deg);}
  to   {transform: rotate3d(-1, 0, 0, 102deg);}}
@keyframes out-right {
  from {transform: rotate3d(0, 0, 0, 0deg);}
  to   {transform: rotate3d(0, -1, 0, 102deg);}}
@keyframes out-bottom {
  from {transform: rotate3d(0, 0, 0, 0deg);}
  to   {transform: rotate3d(1, 0, 0, 101deg);}}
@keyframes out-left {
  from {transform: rotate3d(0, 0, 0, 0deg);}
  to   {transform: rotate3d(0, 1, 0, 102deg);}}
              
            
!

JS

              
                

// - Noel Delgado | @pixelia_me


var nodes  = document.querySelectorAll('li'),
    _nodes = [].slice.call(nodes, 0);

var getDirection = function (ev, obj) {
    var w = obj.offsetWidth,
        h = obj.offsetHeight,
        x = (ev.pageX - obj.offsetLeft - (w / 2) * (w > h ? (h / w) : 1)),
        y = (ev.pageY - obj.offsetTop - (h / 2) * (h > w ? (w / h) : 1)),
        d = Math.round( Math.atan2(y, x) / 1.57079633 + 5 ) % 4;
  
    return d;
};

var addClass = function ( ev, obj, state ) {
    var direction = getDirection( ev, obj ),
        class_suffix = "";
    
    obj.className = "";
    
    switch ( direction ) {
        case 0 : class_suffix = '-top';    break;
        case 1 : class_suffix = '-right';  break;
        case 2 : class_suffix = '-bottom'; break;
        case 3 : class_suffix = '-left';   break;
    }
    
    obj.classList.add( state + class_suffix );
};

// bind events
_nodes.forEach(function (el) {
    el.addEventListener('mouseover', function (ev) {
        addClass( ev, this, 'in' );
    }, false);

    el.addEventListener('mouseout', function (ev) {
        addClass( ev, this, 'out' );
    }, false);
});
              
            
!
999px
We'd ask you for an infinite loop joke, but we'd never hear the end of it.

Console