其中如果有问题,有更好的意见或者建议都可在最后留言,都将对您感激不尽。
具体的代码如下:
复制代码 代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<title>图片轮换效果</title>
<style type="text/css">
body, div { margin: 0; paading: 0; font-size: 12px; }
ul, li { margin: 0; padding: 0; list-style: none; }
.clear { clear: both; width: 1px; height: 0px; line-height: 0px; font-size: 1px; }
.left { float: left; }
.right { float: right; }
ul, li { margin: 0; padding: 0; list-style: none; }
.box { width: 960px; margin: 0 auto; padding-top: 15px; }
.flash { position: relative; width: 360px; height: 280px; overflow: hidden; }
.list { position: relative; width: 360px; height: 260px; overflow: hidden; }
.list li img{ position: absolute; left: 0; top: 0; width: 360px; height: 260px;}
.list li { display: none; }
.list .over { display: block;}
.btn { position: absolute; top: 233px; width: 360px; height: 26px; background: #000; line-height: 26px; opacity: 0.7; filter: alpha(opacity=70); text-align: right; }
.btn a { padding: 2px 5px; margin: 0 2px; border: 1px solid #fff; border-radius: 2px; background: #000; color: #fff; text-decoration: none; cursor: pointer; }
.btn .over { background: #f00; }
.btn2 { position: absolute; top: 206px; height:62px; }
.btn2 img { width: 70px; height: 60px; border: 1px solid #ccc; }
.btn2 .over img { border: 1px solid #f00; }
.flash2 { position: relative; width: 800px; }
.flash2 .list { float: left; }
.flash2 .btn2 { float: left; position: static; width: 150px; height: 280px; }
.flash2 .btn2 img { width: 120px; height: 47px; }
</style>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.6.1.min.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/scroll.js">var autoPlay = {
setTimeShow: function(showObj, btnObj, showClass, timer) {
var length = btnObj.length;
var timeId = null;
var index = 0;
if(showObj.length == btnObj.length) {
timeId = window.setInterval(function(){
index = autoPlay.showCon(showObj, btnObj, showClass, index); //返回操作后的index
}, timer);
} else if (length == 1) {
clearInterval(timeId); // 如果只有一张图片,则清除计时器,停止自动播放。
} else {
return false;
}
// 鼠标点击的操作。
btnObj.each(function(i) {
$(this).click(function() {
$(this).addClass(showClass);
btnObj.not($(this)).removeClass(showClass);
showObj.eq(i).show('slow');
showObj.not(showObj.eq(i)).hide();
index = i;
});
});
},
//自动轮换显示
showCon: function(show, btnObj, showClass, index) {
btnObj.eq(index).addClass(showClass);
btnObj.not(btnObj.eq(index)).removeClass(showClass);
show.eq(index).show('slow');
show.not(show.eq(index)).hide();
if (index >= btnObj.length -1) {
index = 0;
} else {
index++;
}
return index; //返回操作后的index
},
};
</script>
<script type="text/javascript">
$(document).ready(function() {
autoPlay.setTimeShow($('#list1 li'), $('#btn1 a'), 'over', 3000);
autoPlay.setTimeShow($('#list2 li'), $('#btn2 a'), 'over', 3000);
autoPlay.setTimeShow($('#list3 li'), $('#btn3 a'), 'over', 3000);
});
</script>
</head>
<body>
<div class="box">
<div class="flash">
<ul class="list" id='list1'>
<li class="over"><img src="/UploadFiles/2021-04-02/11.jpg"><li><img src="images/2.jpg"><li><img src="/UploadFiles/2021-04-02/6.jpg"><li><img src="images/8.jpg"><li><img src="/UploadFiles/2021-04-02/9.jpg"></ul>
<div class="btn" id="btn1">
<a class="over" href="#">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a>
</div>
</div>
</div>
<div class="box">
<div class="flash">
<ul class="list" id='list2'>
<li class="over"><img src="/UploadFiles/2021-04-02/11.jpg"><li><img src="images/2.jpg"><li><img src="/UploadFiles/2021-04-02/6.jpg"><li><img src="images/8.jpg"><li><img src="/UploadFiles/2021-04-02/9.jpg"></ul>
<div class="btn2" id="btn2">
<a class="over" href="#"><img src="/UploadFiles/2021-04-02/11.jpg"></div>
</div>
</div>
<div class="box">
<div class="flash2">
<ul class="list" id='list3'>
<li class="over"><img src="/UploadFiles/2021-04-02/11.jpg"><li><img src="images/2.jpg"><li><img src="/UploadFiles/2021-04-02/6.jpg"><li><img src="images/8.jpg"><li><img src="/UploadFiles/2021-04-02/9.jpg"></ul>
<div class="btn2" id="btn3">
<a class="over" href="#"><img src="/UploadFiles/2021-04-02/11.jpg"></div>
</div>
</div>
</body>
</html>
具体的代码如下:
复制代码 代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<title>图片轮换效果</title>
<style type="text/css">
body, div { margin: 0; paading: 0; font-size: 12px; }
ul, li { margin: 0; padding: 0; list-style: none; }
.clear { clear: both; width: 1px; height: 0px; line-height: 0px; font-size: 1px; }
.left { float: left; }
.right { float: right; }
ul, li { margin: 0; padding: 0; list-style: none; }
.box { width: 960px; margin: 0 auto; padding-top: 15px; }
.flash { position: relative; width: 360px; height: 280px; overflow: hidden; }
.list { position: relative; width: 360px; height: 260px; overflow: hidden; }
.list li img{ position: absolute; left: 0; top: 0; width: 360px; height: 260px;}
.list li { display: none; }
.list .over { display: block;}
.btn { position: absolute; top: 233px; width: 360px; height: 26px; background: #000; line-height: 26px; opacity: 0.7; filter: alpha(opacity=70); text-align: right; }
.btn a { padding: 2px 5px; margin: 0 2px; border: 1px solid #fff; border-radius: 2px; background: #000; color: #fff; text-decoration: none; cursor: pointer; }
.btn .over { background: #f00; }
.btn2 { position: absolute; top: 206px; height:62px; }
.btn2 img { width: 70px; height: 60px; border: 1px solid #ccc; }
.btn2 .over img { border: 1px solid #f00; }
.flash2 { position: relative; width: 800px; }
.flash2 .list { float: left; }
.flash2 .btn2 { float: left; position: static; width: 150px; height: 280px; }
.flash2 .btn2 img { width: 120px; height: 47px; }
</style>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.6.1.min.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/scroll.js">var autoPlay = {
setTimeShow: function(showObj, btnObj, showClass, timer) {
var length = btnObj.length;
var timeId = null;
var index = 0;
if(showObj.length == btnObj.length) {
timeId = window.setInterval(function(){
index = autoPlay.showCon(showObj, btnObj, showClass, index); //返回操作后的index
}, timer);
} else if (length == 1) {
clearInterval(timeId); // 如果只有一张图片,则清除计时器,停止自动播放。
} else {
return false;
}
// 鼠标点击的操作。
btnObj.each(function(i) {
$(this).click(function() {
$(this).addClass(showClass);
btnObj.not($(this)).removeClass(showClass);
showObj.eq(i).show('slow');
showObj.not(showObj.eq(i)).hide();
index = i;
});
});
},
//自动轮换显示
showCon: function(show, btnObj, showClass, index) {
btnObj.eq(index).addClass(showClass);
btnObj.not(btnObj.eq(index)).removeClass(showClass);
show.eq(index).show('slow');
show.not(show.eq(index)).hide();
if (index >= btnObj.length -1) {
index = 0;
} else {
index++;
}
return index; //返回操作后的index
},
};
</script>
<script type="text/javascript">
$(document).ready(function() {
autoPlay.setTimeShow($('#list1 li'), $('#btn1 a'), 'over', 3000);
autoPlay.setTimeShow($('#list2 li'), $('#btn2 a'), 'over', 3000);
autoPlay.setTimeShow($('#list3 li'), $('#btn3 a'), 'over', 3000);
});
</script>
</head>
<body>
<div class="box">
<div class="flash">
<ul class="list" id='list1'>
<li class="over"><img src="/UploadFiles/2021-04-02/11.jpg"><li><img src="images/2.jpg"><li><img src="/UploadFiles/2021-04-02/6.jpg"><li><img src="images/8.jpg"><li><img src="/UploadFiles/2021-04-02/9.jpg"></ul>
<div class="btn" id="btn1">
<a class="over" href="#">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a>
</div>
</div>
</div>
<div class="box">
<div class="flash">
<ul class="list" id='list2'>
<li class="over"><img src="/UploadFiles/2021-04-02/11.jpg"><li><img src="images/2.jpg"><li><img src="/UploadFiles/2021-04-02/6.jpg"><li><img src="images/8.jpg"><li><img src="/UploadFiles/2021-04-02/9.jpg"></ul>
<div class="btn2" id="btn2">
<a class="over" href="#"><img src="/UploadFiles/2021-04-02/11.jpg"></div>
</div>
</div>
<div class="box">
<div class="flash2">
<ul class="list" id='list3'>
<li class="over"><img src="/UploadFiles/2021-04-02/11.jpg"><li><img src="images/2.jpg"><li><img src="/UploadFiles/2021-04-02/6.jpg"><li><img src="images/8.jpg"><li><img src="/UploadFiles/2021-04-02/9.jpg"></ul>
<div class="btn2" id="btn3">
<a class="over" href="#"><img src="/UploadFiles/2021-04-02/11.jpg"></div>
</div>
</div>
</body>
</html>
标签:
图片轮换
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“封装了一个js图片轮换效果的函数”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。