gpt4 book ai didi

jquery - CSS Slide 多主体背景图片

转载 作者:太空宇宙 更新时间:2023-11-03 17:27:38 25 4
gpt4 key购买 nike

下面的 css 代码将图像从右移到左,但无法移动多个图像,也添加了一个图像,但它没有移动。

jsfiddel

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; }
}

最佳答案

请检查此解决方案。这对我有用....

您需要使用 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>

你已经完成了......

关于jquery - CSS Slide 多主体背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31153770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com