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

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.

HTML

              
                <div class="container">
  <div class="left top js-cursor" data-cursor="cursor__left-chevron">Left Chevron</div>
  <div class="left bottom js-cursor" data-cursor="cursor__right-chevron">Right Chevron</div>
  <div class="right top js-cursor" data-cursor="cursor__close">Close</div>
  <div class="right bottom js-cursor" data-cursor="cursor__grab">Grab</div>
</div>

<div class="cursor js-cursor-el" data-module="cursor" data-cursor="cursor__close">
  <div class="cursor__cursor">

    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="100px" viewBox="0 0 80 100" style="enable-background:new 0 0 80 100;" xml:space="preserve">
      <polyline id="cursor__shape" class="cursor__shape cursor__right-chevron" points="36,58 44,50 36,42 "/>
      <polyline id="left-chevron" class="cursor__shape cursor__left-chevron" points="44,58 36,50 44,42 "/>
      <g id="close" class="cursor__shape cursor__close">
        <line class="st0" x1="32" y1="42" x2="48" y2="58"/>
        <line class="st0" x1="48" y1="42" x2="32" y2="58"/>
      </g>
      <g id="grab" class="cursor__shape cursor__grab">
        <polyline id="right-chevron_1_" class="st0" points="49.5,58 57.5,50 49.5,42   "/>
        <polyline id="left-chevron_1_" class="st0" points="30.5,58 22.5,50 30.5,42  "/>
        <line class="st0" x1="22.5" y1="50" x2="57.5" y2="50"/>
      </g>
      <g id="hamburger" class="cursor__shape cursor__hamburger">
        <line stroke-width="2" x1="24.7" y1="42.5" x2="55.3" y2="42.5"/>
        <line stroke-width="2" x1="24.7" y1="50" x2="55.3" y2="50"/>
        <line stroke-width="2" x1="24.7" y1="57.5" x2="47.7" y2="57.5"/>
      </g>
    </svg>

  </div>
              
            
!

CSS

              
                $cursorSize: 80px;
$white: #fff;
$blue: blue;
$black: #000;
$margin: 2vw;
$desktop: 700px;
$cubic-bezier-default: cubic-bezier(0.19, 1, 0.22, 1);

body.is-cursor-active {
  cursor: none;

  .cursor {
    .cursor__shape {
      transition: all 0.6s $cubic-bezier-default 0.2s;
    }
    &.is-mouse-down {
      .cursor__cursor {
        transform: scale(0.9) translate3d(-50%, -50%, 0) rotate(0deg);
      }
    }
  }
}

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 502;
  pointer-events: none;

  &.is-active {
    .cursor__cursor {
      transform: scale(1) translate3d(-50%, -50%, 0) rotate(0deg);
    }

    &[data-cursor="cursor__right-chevron"] {
      .cursor__right-chevron {
        opacity: 1;
        transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
      }
    }
    
    &[data-cursor="cursor__left-chevron"] {
      .cursor__left-chevron {
        opacity: 1;
        transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
      }
    }

    &[data-cursor="cursor__close"] {
      .cursor__close {
        opacity: 1;
        transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
      }
    }

    &[data-cursor="cursor__grab"] {
      .cursor__grab {
        opacity: 1;
        transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
      }
    }

    &[data-cursor="cursor__hamburger"] {
      .cursor__hamburger {
        opacity: 1;
        transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
      }
    }
  }

  svg {
    
    position: absolute;
    top: 50%;
    left: 50%;
    stroke: $white;
    fill: none;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 50px;
    @include mq($desktop) {
      width: 80px;
      height: 100px;
    }
    
    line {
      stroke: $white;
    }
  }
}

.cursor[data-cursor="cursor__right-chevron"] {
  .cursor__right-chevron {
    transform: scale(0.1) translate3d(-20px, 0, 0) rotate(0deg);
  }
}

.cursor[data-cursor="cursor__left-chevron"] {
  .cursor__left-chevron {
    transform: scale(0.1) translate3d(20px, 0, 0) rotate(0deg);
  }
}

.cursor[data-cursor="cursor__grab"] {
  .cursor__grab {
    transform: scale(0.1) translate3d(0, 10px, 0) rotate(0deg);
  }
}

.cursor[data-cursor="cursor__close"] {
  .cursor__close {
    transform: scale(0.1) translate3d(0, 0, 0) rotate(-180deg);
  }
}

.cursor[data-cursor="cursor__hamburger"] {
  .cursor__hamburger {
    stroke: 2px solid $white;
    transform: scale(0.1) translate3d(0, 0, 0) rotate(0deg);
  }
}

.cursor__cursor {
  
  border-radius: 50%;
  background-color: $blue;
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: 0% 0%;
  transform: scale(0) translate3d(-50%, -50%, 0) rotate(0deg);
  filter: drop-shadow(5px 10px 20px rgba($black, 0.3));
  transition: transform 0.6s $cubic-bezier-default;
  
   width: 40px;
  height: 40px;

    @include mq($desktop) {
      width: 80px;
      height: 80px;
    }
}

.cursor__shape {
  opacity: 0;
  transform-origin: 50% 50%;
  transition: none;
  transform: scale(0.1) translate3d(0, 0, 0) rotate(0deg);
}



// Demo purposes only
body {
  background-color: lightcyan;
  user-select: none;
}
.container {
  height: 100vh;
  
  @include mq($desktop) {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center; 
  }
}

.left, .right {
  display: flex;
  justify-content: center;
  align-items: center;
  text-transform: uppercase;
  font-family: 'inconsolata', 'courier new', monospace;
  font-weight: bold;
  color: $white;
  letter-spacing: 0.25em;
  font-size: 0.8em;
  height: 25vh;
  
  @include mq($desktop) {
    height: calc(50vh - #{$margin * 2});
    width: calc(50% - #{$margin * 2});
    margin: $margin;
  }
  
}
.left {
  left: 0;
}
.right {
  left: 50%;
}
.top {
  top: 0;
}
.bottom {
  bottom: 0;
}
.top.left {
  background-color: MidnightBlue;
}

.top.right {
  background-color: Orange;
}

.bottom.left {
  background-color: MediumAquamarine;
}
.bottom.right {
  background-color: tomato;
}

.js-cursor {
  @include mq($desktop) {
    &:nth-child(n+3) {
      margin-top: 0;
    }
  }
}
              
            
!

JS

              
                var $cursor = $('.js-cursor-el');
var $body = $('body');
var cursorSize = '80';

var mouseIsDown = false,
lastMousePosition = { x: 0, y: 0 };

function onMouseDown() {
  $cursor.addClass('is-mouse-down');
  mouseIsDown = true;
  requestAnimationFrame(update);
}

function onMouseUp() {
  $cursor.removeClass('is-mouse-down');
  mouseIsDown = false;
  requestAnimationFrame(update); 
}

function onMouseMove(evt) {
  lastMousePosition.x = evt.clientX;
  lastMousePosition.y = evt.clientY;
  requestAnimationFrame(update);
}

function update() {
  // Get the element we're hovered on
  var hoveredEl = document.elementFromPoint(lastMousePosition.x, lastMousePosition.y);

  // Check if the element or any of its parents have a .js-cursor class
  if ($(hoveredEl).parents('.js-cursor').length || $(hoveredEl).hasClass('js-cursor')) {
    var $whichCursor = $(hoveredEl).parents('.js-cursor').attr('data-cursor') || $(hoveredEl).attr('data-cursor');
    $body.addClass('is-cursor-active');
    $cursor.addClass('is-active');
    $cursor.attr('data-cursor', $whichCursor);
  } else {
    $body.removeClass('is-cursor-active');
    $cursor.removeClass('is-active');
  }

  // now draw object at lastMousePosition
  $cursor.css({
    'transform': `translate3d(${lastMousePosition.x}px, ${lastMousePosition.y}px, 0)`
  });
}

document.addEventListener('mousedown', onMouseDown, false);
document.addEventListener('mouseup',   onMouseUp,   false);
document.addEventListener('mousemove', onMouseMove, false);

// Clear on scroll
document.addEventListener('scroll', update, false);
              
            
!
999px

Console