In this post am going to show how to move background image using css.Here two jQuery methods are used to perform this action.
setInterval() :
The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).
css():
The css() method sets or returns one or more style properties for the selected elements.
Please share your comments and feedback.Thanks.Please subscribe my updates via email.
setInterval() :
The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).
css():
The css() method sets or returns one or more style properties for the selected elements.
Jquery function
<script type="text/javascript">
$(function(){
var x = 0;
setInterval(function(){
x-=1;
$('.clouds').css('background-position', x + 'px 0'); //replace with your class name or ID name
}, 70);
})
</script>
$(function(){
var x = 0;
setInterval(function(){
x-=1;
$('.clouds').css('background-position', x + 'px 0'); //replace with your class name or ID name
}, 70);
})
</script>
HTML
<div class="clouds"></div>
Good Work - keep doing it
ReplyDeleteI agree with you ... This code is extremely expensive...
ReplyDelete