Home » Web » CSS (page 20)


Moving Backgrounds With Mouse Position

Let’s say you wanted to move the background-position on an element as you mouse over it to give the design a little pizzazz. You have an element like this: <div class="module" id="module"></div> And you toss a background on it: .module { background-image: url(big-image.jpg); } You can adjust the background-position in JavaScript like this: const el = document.querySelector("#module"); el.addEventListener("mousemove", (e) => ...

Read More »

Powered by WP Robot