Sep 5, 2020
White Arrow icon
Back to all Elements

Hover to reveal Mask

A fixed background image that is revealed by mouse hover all over the section

I recreated this codepen by @suez in Webflow.

Create the following hierarchy:

  1. Full page div/section
  2. Add a div with the size and shape of your mask revealer and a background image of your choice and position:absolute. Place it inside the full page section.
  3. Paste this code to your page custom code section, before </body> tag:

<script>
 document.addEventListener('DOMContentLoaded', (ev) => {
   const circle = document.querySelector('.hover-div');
   const circleHalf = circle.offsetWidth / 2;

   addEventListener("mousemove", (e) => {
     console.log(e.pageX, e.pageY);
     circle.style.left = e.pageX - circleHalf + "px";
     circle.style.top = e.pageY - circleHalf + "px";
   });
 });
</script>

Copy
  1. Replace the ".hover-div" with your mask (circle) div classname (replace only the hover-div, keep the ' ' and the .
  2. Publish :) 

Preview:

browser mockup
Share:
Heart icon

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:

Scaleable Vanilla JS Nested Tabs

JavaScript
Cloneable
Code

Nested tabs in an accordion template

Read more
Blue arrow iconWhite Arrow icon

Buttons Hover Interactions

Cloneable
Interactions

A small collection of buttons and hover interactions.

Read more
Blue arrow iconWhite Arrow icon

3d Video Slider (swiper.js)

Cloneable
CMS
JavaScript

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

Read more
Blue arrow iconWhite Arrow icon