<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>轮播图</title>
<style type="text/css">
.imgBox{
border-top: 2px solid cadetblue;
width: 100%;
height: 250px;
margin: 0 auto;
}
.imgBox img{
width: 100%;
height: 250px;
margin: 0 auto;
padding-top: 30px;
}
.img1{
display: block;
}
.img2{
display: none;
}
.img3{
display: none;
}
</style>
</head>
<body>
<p>图片轮播</p>
<div class="imgBox">
<img class="img-slide img1" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.jj20.com%2Fup%2Fallimg%2F1111%2F06041Q43S7%2F1P604143S7-9.jpg&refer=http%3A%2F%2Fpic.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644316528&t=b8f919e19c4868e50062b586da5cf41f" alt="1">
<img class="img-slide img2" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2F25%2Fbb%2F55%2F25bb5526e31389a07094cc12dee17453.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644316562&t=3f216b7d013b9ec0ee17ed57f5da3471" alt="2">
<img class="img-slide img3" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.jj20.com%2Fup%2Fallimg%2F1111%2F06041Q43S7%2F1P604143S7-9.jpg&refer=http%3A%2F%2Fpic.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644316528&t=b8f919e19c4868e50062b586da5cf41f" alt="3">
</div>
</body>
<script type="text/javascript">
var index=0;
//效果
function ChangeImg() {
index++;
var a=document.getElementsByClassName("img-slide");
if(index>=a.length) index=0;
for(var i=0;i<a.length;i++){
a[i].style.display='none';
}
a[index].style.display='block';
}
//设置定时器,每隔两秒切换一张图片
setInterval(ChangeImg,3000);
</script>
</html>
|
免责声明:
1,海欣资源网所发布的资源由网友上传和分享,不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
2,海欣资源网的资源来源于网友分享,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3,海欣资源网所发布的资源由网友上传和分享,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
4,如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉,联系方式邮箱 haixinst@qq.com
|