<span style="white-space: nowrap;">完整的js图片转动特效代码,复制就可使用,代码如下:</span>
<span style="white-space: nowrap;"><br/></span>
<br/>
<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<title>图片转动特效</title>
<styletype="text/css">
.box{
width:200px;
height:200px;
position:relative;
margin:20pxauto;
}
.boximg{
position:absolute;
left:0;
top:0;
width:200px;
height:200px;
}
</style>
</head>
<body>
<divclass="box">
<imgsrc="1.jpg"alt="">
<imgsrc="2.jpg"alt="">
<imgsrc="3.jpg"alt="">
</div>
<scripttype="text/javascript">
varbox=document.querySelector('.box');
varimgs=box.querySelectorAll('img');
varindex=0;
setInterval(function(){
imgs[index].style.opacity=0;
index++;
if(index>=imgs.length){
index=0;
}
imgs[index].style.opacity=1;
},1000);
</script>
</body>
</html><span style="white-space: nowrap;"></span><br/>
<br/>
发表评论