Cursor · 03 of 22
Mask Reveal
Cursor acts as a window
<div class="mask-area" id="maskArea">
<div class="mask-bg">HOVER TO REVEAL</div>
<div class="mask-front" id="maskFront">HOVER TO REVEAL</div>
</div>
.mask-area {
position: relative;
height: 240px;
background: #000;
overflow: hidden;
font-family: sans-serif;
}
.mask-bg,
.mask-front {
position: absolute;
width: 100%; height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
font-weight: 700;
}
.mask-bg { color: #333; }
.mask-front {
color: #7c5cff;
background: #111;
clip-path: circle(0% at 50% 50%); /* opened up by JS */
}
var area = document.getElementById('maskArea');
var front = document.getElementById('maskFront');
var HOLE = '25%'; // circle radius while hovering
area.addEventListener('mousemove', function (e) {
var rect = area.getBoundingClientRect();
var x = e.clientX - rect.left;
var y = e.clientY - rect.top;
front.style.clipPath = 'circle(' + HOLE + ' at ' + x + 'px ' + y + 'px)';
});
area.addEventListener('mouseleave', function () {
front.style.clipPath = 'circle(0% at 50% 50%)';
});