下面的css代码将图像从右向左移动但是无法移动多个图像也添加了图像但是没有移动。
body {
background-image: url("http://www.animaatjes.nl/disney-plaatjes/disney-plaatjes/finding-nemo/nemo11.gif"), url("http://www.marcofolio.net/images/stories/programming/webdesign/bgimg_slideshow/slideshow.png");
background-repeat: no-repeat;
background-position: 50% 0%, 0;
-moz-animation: swim 2s linear 0s infinite;
-webkit-animation: swim 2s linear 0s infinite;
animation: swim 2s linear 0s infinite;
}
@-moz-keyframes swim {
from { background-position: 200% 0, 0 0; }
to { background-position: -100% 0, 0 0; }
}
@-webkit-keyframes swim {
from { background-position: 200% 0, 0 0; }
to { background-position: -100% 0, 0 0; }
}
@keyframes swim {
from { background-position: 200% 0, 0 0; }
to { background-position: -100% 0, 0 0; }
}
答案 0 :(得分:0)
请检查此解决方案。这对我有用....
您需要使用jquery脚本。
var currentBackground = 0;
var backgrounds = [];
backgrounds[0] = 'http://www.animaatjes.nl/disney-plaatjes/disney-plaatjes/finding-nemo/nemo11.gif';
backgrounds[1] = 'http://www.marcofolio.net/images/stories/programming/webdesign/bgimg_slideshow/slideshow.png';
function changeBackground() {
currentBackground++;
if(currentBackground == 2) currentBackground = 0;
$('body').fadeOut(100,function() {
$('body').css({
'background-image' : "url('" + backgrounds[currentBackground] + "')"
});
$('body').fadeIn(100);
});
setTimeout(changeBackground, 2000);
}
$(document).ready(function() {
setTimeout(changeBackground, 2000);
});
change your css to this :

body {
background-repeat: no-repeat;
background-position: 50% 0%, 0;
-moz-animation: swim 2s linear 0s infinite;
-webkit-animation: swim 2s linear 0s infinite;
animation: swim 2s linear 0s infinite;
}
@-moz-keyframes swim {
from { background-position: 200% 0, 0 0; }
to { background-position: -100% 0, 0 0; }
}
@-webkit-keyframes swim {
from { background-position: 200% 0, 0 0; }
to { background-position: -100% 0, 0 0; }
}
@keyframes swim {
from { background-position: 200% 0, 0 0; }
to { background-position: -100% 0, 0 0; }
}
Add jquery library if you have not added....

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
&#13;
你做完了.....