A simple mouse hover position detection effect that controls horizontal image movement.
Add-ons

Plugin Description: Handwritten native JavaScript implementation with no jQuery dependency. Easy to use, with detailed instructions.
Usage
Reference
1 2 | <link rel="stylesheet" href="css/bgMove.css"><script src="js/bgMove.js"></script> |
CSS
1 2 3 4 | #move { background: url(images/bg1.jpg);}// Sets the background image |
html
1 2 3 4 | <div id="move"> <div id="moveL"></div> <div id="moveR"></div></div> |
Initialization
1 2 3 4 5 6 | <script> bgMove({ jump : 15, // Movement speed. Optional; can be omitted. Defaults to 10. bgImgurl : "images/bg1.jpg" // Background image path in the HTML, which is required. })</script> |
note:
moveL and moveR are positioned with z-index set to 1. If there are clickable elements on the page, their z-index must be greater than 1.
The background image must be wider than the screen for the effect to work properly.
评论