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

              
                <!-- https://stackoverflow.com/questions/50538768/css-custom-cursor-that-changes-depending-on-hovered-element-flickers-when-movi -->
<div id="wrapper">
  <div id="box-1" class="box">sphere</div>
  <div id="box-2" class="box">circle outline</div>
  <div id="box-3" class="box">circle pin</div>
  <div id="box-4" class="box">circle color gradient</div>
  <div id="circle"></div>
</div>

<div class="citation">
  <p>Recreation of the solution <a class="cite-link" href="https://stackoverflow.com/questions/50538768/css-custom-cursor-that-changes-depending-on-hovered-element-flickers-when-movi" target="_blank">here</a> for my own edification.</p>
</div>
              
            
!

CSS

              
                html {
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
  &:focus {
    outline: none;
  }
}

* {
  font-family: monaco, courier;
}

//

body {
  position: relative;
  margin: 0;
  height: 100vh;
  background-color: #acd1d2;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: monospace;
  cursor: none;
}

#wrapper {
  position: relative;
  width: 70%;
  height: 80%;
}

#circle {
  position: fixed;
  z-index: 5;
  width: 32px;
  height: 32px;
  background-color: white;
  border-radius: 50%;
  pointer-events: none;
  transition:
    background ease-in 10ms,
    box-shadow ease-in 150ms,
    transform ease-in 150ms;
  /* promote it to its own layer to enable  hardware accelerated rendering: */
  transform: translate3d(0, 0, 0);
}

.box {
  height: 25%;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;  
}

#box-1 {
  background-color: #e8edf3;
}
  
#box-1:hover ~ #circle {
  background-color: #e6cf8b;
  box-shadow: 0 0 0 0 transparent, inset 0em -0.3em 0.4em 0.2em #ca9e03a6;
}

#box-2 {
  background-color: #e6cf8b;
}
  
#box-2:hover ~ #circle {
  background-color: transparent;
  /* use box-shadow instead of border to avoid changing the dimensions of the cursor, which would force it off-center until the mouse moves again: */
  box-shadow: 0 0 0 3px #E91E63;
}

#box-3 {
  background-color: #b56969; 
}
  
#box-3:hover ~ #circle {
  /* change size with scale() instead of width and height for better performance: */
  transform: scale(0.5) translate3d(0, 0, 0);
  background-color: #e6cf8b;
} 

#box-4 {
  color: white;
  background-color: #22264b;
}

#box-4:hover ~ #circle {
  background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
}

// citation

.citation {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 100;
  background: #91b9ba;
  cursor: default;
  p {
    margin: 0;
    padding: 10px;
    font-size: 12px;
    color: #063738;
    a {
      color: DarkBlue;
      cursor: pointer;
      &:hover {
        color: Indigo;
      }
    }
  }
}
              
            
!

JS

              
                const circle = document.getElementById('circle');
const circleStyle = circle.style;

document.addEventListener('mousemove', e => {
  window.requestAnimationFrame(() => {
    circleStyle.top = `${ e.clientY - circle.offsetHeight/2 }px`;
    circleStyle.left = `${ e.clientX - circle.offsetWidth/2 }px`;
  });
});
              
            
!
999px

Console