Oct 17, 2019
White Arrow icon
Back to all Elements

Cursor Blend

A few short lines of code, to replace the pointer with an interactive color element.

1. Giving an element a mix-blend-mode property so it will change it's color by the color of the element behind.

We start by creating a div and giving it the class .cursor and these properties:

  • width: 30px
  • height: 30px
  • margin-top: -15px
  • margin-left: -15px
  • position: absolute
  • z-index: 9999
  • background: white
  • border-radius: 30px

Now we need to add a bit of code for that to work well.

1st part is making sure we won't get horizontal scroll bar once the element (pointer) is outside of the viewport.

2nd part is giving the .cursor class the mix-blend-mode and making it "transparent" so any clicks of the actual pointer will "go through" to the element below.

<style>

 

 ‍ html,

 body {

   max-width: 100%;

   overflow-x: hidden;

 }

 .cursor {

   mix-blend-mode: difference;

   pointer-events: none;

 }

</style>

Copy

2. Replacing the pointer with the new element.

Now we need edit the body TAG to make the cursor "disappear"

Webflow's Style panel, body TAG selected

And now all that is left to do is to "glue" the .cursor element to the mouse movements with a bit of JavaScript

<script>

 ‍

 var $cursor = $('.cursor');‍

 

 function moveCursor(e) {

   $cursor.css({

     "top": e.pageY,

     "left": e.pageX

   });

 }‍

 

 $(window).on('mousemove', moveCursor);‍

</script>

Copy

Preview:

Share:

When your bath soap bar gets too small to use, don't throw it away! open the next bar, and when you finish showering, stick the small old bar to the back of the new bar. Onces they both dry, they will become one.

Might also interest you:

3d Video Slider (swiper.js)

Cloneable
CMS
JavaScript

A 3d slider with video items, plays and pauses on click & slide change.

Read more
White Arrow icon

Webflow Dashboard Workspaces Hack

Webflow UI Hack
Code
CSS

Convert the Workspaces dropdown to an open sidebar with custom order.

Read more
White Arrow icon

Glossary

Cloneable
JavaScript
CMS

A clonable for creating an Alphabetical glossary

Read more
White Arrow icon