gpt4 book ai didi

javascript - 幻灯片无法正常运行 javascript

转载 作者:行者123 更新时间:2023-11-28 18:02:41 25 4
gpt4 key购买 nike

我的幻灯片放映有问题。目前,第一个图像循环一直闪回“image3”,但一旦幻灯片放映经过第一个循环,它似乎就可以正常运行。我需要幻灯片第一次正常运行。任何帮助,将不胜感激!这是我的相关代码:

HTML

<div id="slideshow">
<div>
<img src="img/image1.jpg" alt="Image1" class="scale-with-grid" width="100%" height="100%" />
</div>
<div>
<img src="img/image2.jpg" alt="Image2" class="scale-with-grid" width="100%" height="100%" />
</div>
<div>
<img src="img/image3.jpg" alt="Image2" class="scale-with-grid" width="100%" height="100%" />
</div>
</div>

CSS

#slideshow {
margin: auto;
position: relative;
width: 637px;
height: 396px;
padding: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}
#slideshow > div {
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
}

Javascript

$("#slideshow > div:gt(0)").hide();

setInterval(function () {
$('#slideshow > div:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#slideshow');
}, 5000);

谢谢!

最佳答案

看看我网站上的一些源代码:

<div id="mySwipe" style="max-width: 500px; margin: 0px auto; visibility: visible;" class="swipe">

<div class="swipe-wrap" style="width: 3000px;">



<div data-index="0" style="width: 500px; left: 0px; transition: 300ms; -webkit-transition: 300ms; -webkit-transform: translate(-500px, 0px) translateZ(0px);"><img src="http://i.imgur.com/oFnHbEQ.png" style="width:" "100%"=""></div>

<div data-index="1" style="width: 500px; left: -500px; transition: 300ms; -webkit-transition: 300ms; -webkit-transform: translate(-500px, 0px) translateZ(0px);"><img src="http://i.imgur.com/qFUDwaC.png" style="width:" "100%"=""></div>

<div data-index="2" style="width: 500px; left: -1000px; -webkit-transition: 300ms; transition: 300ms; -webkit-transform: translate(-500px, 0px) translateZ(0px);"><img src="http://i.imgur.com/XKxbTCK.png" style="width:" "100%"=""></div>

<div data-index="3" style="width: 500px; left: -1500px; -webkit-transition: 300ms; transition: 300ms; -webkit-transform: translate(0px, 0px) translateZ(0px);"><img src="http://i.imgur.com/a1YKHeR.png" style="width:" "100%"=""></div>

<div data-index="4" style="width: 500px; left: -2000px; -webkit-transition: 0ms; transition: 0ms; -webkit-transform: translate(500px, 0px) translateZ(0px);"><img src="http://i.imgur.com/YzLZS1Y.png" style="width:" "100%"=""></div>

<div data-index="5" style="width: 500px; left: -2500px; -webkit-transition: 300ms; transition: 300ms; -webkit-transform: translate(500px, 0px) translateZ(0px);"><img src="http://i.imgur.com/F05kEd7.png" style="width:" "100%"=""></div>

</div>

="text-align:center;padding-top:20px;">


<button onclick="mySwipe.prev()">prev</button>

<button onclick="mySwipe.next()">next</button>


</div>

<script async="" src="//www.google-analytics.com/analytics.js"></script><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script src="swipe.js"></script>

<script>

var elem = document.getElementById('mySwipe');

window.mySwipe = Swipe(elem, {

startSlide: 0,

auto: 2000,

continuous: true,

disableScroll: true,

stopPropagation: true,

callback: function(index, element) {},

transitionEnd: function(index, element) {}

});

关于javascript - 幻灯片无法正常运行 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20130319/

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