Javascript 使用java脚本播放幻灯片动画
以下代码用于带动画的幻灯片放映。我希望在每次转换之前,即图像更改之前,动画结束后会保持1-2秒。我该怎么办Javascript 使用java脚本播放幻灯片动画,javascript,html,css,Javascript,Html,Css,以下代码用于带动画的幻灯片放映。我希望在每次转换之前,即图像更改之前,动画结束后会保持1-2秒。我该怎么办 <html> <style> #slideshow{width:310;height:210;border-style:solid;} #imge{ position:absolute;left:15;top:15; animation:myfirst 5s;
<html>
<style>
#slideshow{width:310;height:210;border-style:solid;}
#imge{
position:absolute;left:15;top:15;
animation:myfirst 5s;
animation-iteration-count:infinite;
-webkit-animation:myfirst 5s;
-webkit-animation-iteration-count:infinite;
}
@keyframes myfirst
{
from {width:0;}
to{width:300;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
from {width:0;}
to {width:300;}
}
</style>
<body>
<div id="slideshow">
<img id="imge" src="img1.jpg" height="200" width="300"/>
</div>
<script>
var count=1;
mf();
function mf(){
document.getElementById("imge").src="img"+count+".jpg";
if(count<3)
count++;
else
count=1;
setTimeout("mf()",5000);
}
</script>
</body>
</html>
#幻灯片{宽度:310;高度:210;边框样式:实心;}
#伊姆奇{
位置:绝对;左侧:15;顶部:15;
动画:我的第一个5s;
动画迭代次数:无限;
-webkit动画:MyFirst5s;
-webkit动画迭代计数:无限;
}
@关键帧myfirst
{
从{宽度:0;}
至{宽度:300;}
}
@-webkit为myfirst/*Safari和Chrome设置关键帧*/
{
从{宽度:0;}
至{宽度:300;}
}
var计数=1;
mf();
函数mf(){
document.getElementById(“imge”).src=“img”+count+”.jpg”;
如果(计数<代码>
var计数=0;
mf();
函数mf()
{
document.getElementById(“imge”).src=“img”+count+”.jpg”;
如果(计数=3)
{
setTimeout(“mf()”,8000);
}否则{
如果(count)既然你已经在使用关键帧了,为什么不尝试只使用CSS的幻灯片呢?所以你希望我只使用CSS而不是javascript..只是建议你可以..但是请告诉我如何在动画结束后保持图像1-2秒。。
<script>
var count=0;
mf();
function mf()
{
document.getElementById("imge").src="img"+count+".jpg";
if(count==3)
{
setTimeout("mf()",8000);
}else{
if(count<3)
count++;
else
count=1;
setTimeout("mf()",5000);
}}
</script>