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).ready(function() {
 var $magic = $(".hover-div"),
     magicWHalf = $magic.width() / 2;
 $(document).on("mousemove", function(e) {
   $magic.css({"left": e.pageX - magicWHalf, "top": e.pageY - magicWHalf});
 });
});
</script>

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

Preview:

browser mockup
Share:
Heart icon

Whenever possible, use Class Names to target the elements in your interaction. You never know when you'll need to duplicate and use it somewhere else...

Might also interest you:

CMS Autocomplete

Cloneable
CMS
JavaScript

A short JavaScript code for transferring a CMS list into an autocomplete on an input field.

Read more
Blue arrow iconWhite Arrow icon

Auto get Current Year

Cloneable
Code
JavaScript

Automatically insert the current year to any element with the class of 'year'

Read more
Blue arrow iconWhite Arrow icon

Scroll Menu to Current Link

Cloneable
CMS
Code

Using JS to scroll a div (menu) to the current link inside.

Read more
Blue arrow iconWhite Arrow icon