Move multiple backgrounds infinitely using CSS

后端 未结 3 919
予麋鹿
予麋鹿 2021-01-07 08:45

I have two backgrounds:

body {
    background-image: url(img/nemo.png),url(img/ocean.png);
}

How do I make nemo.png background

3条回答
  •  孤城傲影
    2021-01-07 09:05

    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 the body of your page.

    Then create a div which with the following css:

    width:100%; 
    height:100%;
    background-position:center center;
    background-image: url(img/moving-nemo.gif);
    

    The div will be an all-encompassing container for all of your content which will give you a layered background effect.

提交回复
热议问题