Home
Products
Grids
Blog
Support
Donate
About
   

Change background image on scroll

A cool change of the CSS background-image property with a few lines of JavaScript.
Rerun
HTML
CSS
Script
The JavaScript above listens for a scroll event and then removes the head-1 class and replaces it with the head-2 class.

Scroll down, scroll up

HTML
CSS
Script
This example uses the offsetTop property, which returns the distance of the element relative to the offsetParent value.
Before you go

For more articles like this, and to help us develop our open source plugins, we need your help. Please donate.

Donate
Latest & featured