With one simple sentence of jQuery we can animate the position of the background image , in the following example we have a div with a background image.
#leftThe jQuery instruction:
{
width:250px;
height:500px;
background-image:url(Images/test.png);
background-position:0px;
background-repeat:no-repeat;
float:left;
overflow:hidden;
z-index:-1;
}
<div id="left"></div>
We just put in the animate the property backgroundPosition and the new position, after defining the speed of the animation.
$("#left").animate({ backgroundPosition: "-500px" }, 700);
0 comments:
Post a Comment