Animated Text-Mask Background with jQuery and CSS3

Animated Text-Mask Background with jQuery and CSS3
File Size: 1.88 KB
Views Total: 4961
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

A fancy jQuery & CSS3 solution for textured text that places an image inside of your text as an animated background that reacts to mouse move. Currently works in webkit browsers like Chrome, Safari, Opera, etc, not Firefox. To solve that you could use an SVG instead of pure text.

How to use it:

1. Wrap the text to be filled by image or texture into a DIV element.

<div class="title">jQuery</div>

2. Add a background image to the element and set the background-clip to text.

.title {
  color: transparent;
  background: url("demo.jpg") repeat;
  background-position: 40% 50%;
  -webkit-background-clip: text;
  position: relative;

3. Load the needed jQuery library at the bottom of the web page.

<script src="//"></script>

4. Active the animated & interactive background that moves on mouse move.

  var mouseX, mouseY;
  var ww = $( window ).width();
  var wh = $( window ).height();
  var traX, traY;
     mouseX = e.pageX;
     mouseY = e.pageY;
    console.log(mouseX + " e mouseY" + mouseY);
    console.log(ww + " e wh" + wh);
    traX = ((4 * mouseX) / 570) + 40;
    traY = ((4 * mouseY) / 570) + 50;
    $(".title").css({"background-position": traX + "%" + traY + "%"});

This awesome jQuery plugin is developed by dghez. For more Advanced Usages, please check the demo page or visit the official website.