1

首先我想问我是否可以用 css 更改背景图像(如果不是在 jquery 或 javascript 中,关键是构建简单的代码)。好吧,第二,我想将背景分成三个不同大小的部分,然后将照片放在每个部分(三张照片)中,我希望每个部分的照片在几秒钟后自动随机更改。例如,我在背景中有 part1 part2 part3,我有 image1 image2 image3 image4 image5 image6 image7 所以它必须是这样的(例如):

part1=image6
part2=image3
part3=image7

3 秒后:

part1=image2(the other stays as it is)

2秒后:

part2=image1
part3=image4

5秒后:

part3=image2
part1=image4

就像那样。似乎每个用户个人资料中照片的 instagram 背景,是的,我想要这样的东西。

4

1 回答 1

0

如果使用 css 可能是这样的

@-webkit-keyframes changeBG {
from {background: url(image1.jpg);}
to { background: url(image2.jp);}
}
@-moz-keyframes changeBG {
from {background: url(image1.jpg);}
to {background: url(image1.jpg);}
}

或者如果您想使用更多图像,您可以使用 css 关键帧从 0% 到 100% 像这样

@-webkit-keyframes changeBG {
        0% {background: url(image1.jpg);}
        10% { background: url(image2.jp);}
20% { background: url(image3.jp);}
30% { background: url(image4.jp);}
40% { background: url(image5.jp);}
50% { background: url(image6.jp);}
60% { background: url(image7.jp);}
70% { background: url(image8.jp);}
80% { background: url(image9.jp);}
90% { background: url(image10.jp);}
100% { background: url(image11.jp);}
        }
于 2013-05-05T11:32:58.340 回答