0
我想在每次点击change_photo按钮时移动div,但此代码只运行一次,我不需要无限循环,每次点击时我都希望div移动。我想在css3中每点击一次动画图像
是css:
<style>
@-webkit-keyframes myfirst
{
0% {left:0px}
100% {left:100%}
}
#images {
width: 1000px;
height: 300px;
overflow: hidden;
position: relative;
margin: 20px auto;
}
#im{ position:relative;}
</style>
这是HTML代码:
<div id="images" style="">
<img id="im" src="images/banner.jpg"
style="width: 833px; height: 179px;" />
</div>
<input type="button" value="change_photo" onclick="animate();" />
</div>
<script>
function animate() {
var im = document.getElementById("im");
im.style.webkitAnimation = "myfirst 3s";
}
</script>
感谢维尼特,但我想这样做时,点击按钮 – user1230622
@ user1230622 OK,添加你的代码。而阿德里安也是对的。 – svineet