废话不多说,直接上代码:
<style>
* {
margin: 0px;
padding: 0px;
}
.stage {
width: 500px;
height: 300px;
border: 5px solid black;
margin: 200px;
position: relative;
overflow: hidden;
}
.to-left,
.to-right {
position: absolute;
top: 0px;
width: 50px;
height: 300px;
background-color: black;
color: white;
font-size: 30px;
text-align: center;
line-height: 300px;
opacity: 0.3;
}
.to-left {
left: 0px;
}
.to-right {
right: 0px;
}
.to-left:hover,
.to-right:hover {
cursor: pointer;
opacity: 0.5;
}
.banner {
width: 3000px;
height: 300px;
}
.items {
float: left;
width: 500px;
height: 300px;
background-color: blanchedalmond;
font-size: 100px;
text-align: center;
line-height: 300px;
}
</style>
</head>
<!--大图轮播特效-->
<body>
<div class="stage">
<div class="to-left">
<</div>
<div class="to-right"</div>
<div class="banner">
<div class="items">1</div>
<div class="items" style="">2</div>
<div class="items" style="">3</div>
<div class="items" style="">4</div>
<div class="items" style="">5</div>
<div class="items">1</div>
</div>
</div>
</body>
</html>
<script>
var to_right = document.getElementsByClassName('to-right')[0];
var to_left = document.getElementsByClassName('to-left')[0];
var banner = document.getElementsByClassName('banner')[0];
var arr = [];
var count = 1;
to_right.onclick = function() {
toRight();
}
function toRight(){
arr.push(window.setInterval("moveLeft()", 30));
}
to_left.onclick = function() {
toLeft();
}
function toLeft(){
arr.push(window.setInterval("moveRight()", 30));
}
function moveLeft() {
if(count < 5) {
if(banner.offsetLeft > count * (-500)) {
banner.style.marginLeft = banner.offsetLeft - 20 + "px";
} else {
for(var x in arr) {
window.clearInterval(arr[x]);
}
count++;
}
// 连接点
}else{
if(banner.offsetLeft > count * (-500)) {
banner.style.marginLeft = banner.offsetLeft - 20 + "px";
} else {
for(var x in arr) {
window.clearInterval(arr[x]);
}
count = 1;
banner.style.marginLeft = 0 + 'px';
}
}
}
function moveRight() {
if(count-1 >0) {
if(banner.offsetLeft < (count-2) * (-500)) {
banner.style.marginLeft = banner.offsetLeft + 20 + "px";
} else {
for(var x in arr) {
window.clearInterval(arr[x]);
}
count--;
}
}
}
window.setInterval("toRight()",1750);
</script>
以上这篇利用JS做网页特效_大图轮播(实例讲解)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
标签:
大图轮播
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无争山庄资源网 Copyright www.whwtcm.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%。
更新日志
2025年10月25日
2025年10月25日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]