I have two backgrounds:
body {
background-image: url(img/nemo.png),url(img/ocean.png);
}
How do I make nemo.png background
move infinitely from left-right but not affecting ocean.png background
?
EDIT: When he reaches the right most edge (and the image is no longer visible), he will appear from the left edge again and start doing the drifting from left-to-right.
Heres an option:
Create an animated GIF from the
nemo.png
which is a simple animation of the image moving from left to right.Then create the layered backgrounds by setting
ocean.png
to the background of thebody
of your page.Then create a
div
which with the following css:The
div
will be an all-encompassing container for all of your content which will give you a layered background effect.This can be done with pure CSS 3, e.g keyframed animations:
Demo: http://jsfiddle.net/dghsV/112
Syntax
The feature is experimental, so vendor-prefixes (eg
-webkit-
) have to be added (see also Can I use CSS3 Animation for compatibility notes). In my demo, I've used all properties, except for the last one.make only ocean the background and create a div with the nemo as background:
than you can animate this div with javascript (jQuery):