




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第js+css实现卡片轮播图效果本文实例为大家分享了js+css实现卡片轮播图效果的具体代码,供大家参考,具体内容如下
实现点击的时候切换卡片,自动轮播,鼠标移入暂停,移出继续轮播,有动画事件
效果就是这样
下面是代码
htmllang="en"
head
metacharset="UTF-8"
metahttp-equiv="X-UA-Compatible"content="IE=edge"
metaname="viewport"content="width=device-width,initial-scale=1.0"
titleDocument/title
style
.box{
width:680px;
padding:50px;
margin:auto;
margin-top:300px;
}
.swiper,
#swiper{
width:830px;
height:200px;
position:relative;
}
.swiperdiv{
display:block;
position:absolute;
width:500px;
height:200px;
overflow:hidden;
left:165px;
top:0;
transition:0.5s;
color:#fff;
font-size:50px;
text-align:center;
line-height:200px;
}
.swiperdiv:nth-child(1){
background:#1ebe09;
}
.swiperdiv:nth-child(2){
background:#323a31;
}
.swiperdiv:nth-child(3){
background:#0985be;
}
.swiperdiv:nth-child(4){
background:#090cbe;
}
.swiperdiv:nth-child(5){
background:#be5109;
}
.swiperdiv:nth-child(6){
background:#be09af;
}
.swiperdiv:nth-child(7){
background:#be8e09;
}
.swiperdiv:nth-child(8){
background:#be0909;
}
.swiperdiv:nth-child(9){
background:#06162c;
}
.swiper.a{
opacity:1;
z-index:23;
-webkit-transform:translateX(255px)translateZ(-300px)rotateY(-45deg);
-ms-transform:translateX(255px)translateZ(-300px)rotateY(-45deg);
transform:perspective(500px)translateX(300px)translateZ(-253px)rotateY(-45deg);
-webkit-box-reflect:below10px-webkit-gradient(linear,lefttop,leftbottom,from(transparent),color-stop(30%,transparent),to(rgba(250,250,250,0.3)));
}
.swiper.b{
opacity:1;
z-index:33;
-webkit-box-reflect:below10px-webkit-gradient(linear,lefttop,leftbottom,from(transparent),color-stop(30%,transparent),to(rgba(250,250,250,0.3)));
transform:translateX(0)translateZ(-100px)rotateY(0deg)
}
.swiper.c{
opacity:1;
z-index:23;
-webkit-box-reflect:below10px-webkit-gradient(linear,lefttop,leftbottom,from(transparent),color-stop(30%,transparent),to(rgba(250,250,250,0.3)));
-webkit-transform:translateX(255px)translateZ(-300px)rotateY(-45deg);
-ms-transform:translateX(255px)translateZ(-300px)rotateY(-45deg);
transform:perspective(500px)translateX(-300px)translateZ(-253px)rotateY(45deg);
}
.swiper.dd{
opacity:0;
z-index:-1;
-webkit-transform:translateX(0)translateZ(-300px)rotateY(0);
-ms-transform:translateX(0)translateZ(-300px)rotateY(0);
transform:perspective(500px)translateX(0)translateZ(-253px)rotateY(0);
}
/style
/head
body
div
divid="swiper"
div1/div
div2/div
div3/div
div4/div
div5/div
div6/div
div7/div
div8/div
div9/div
/div
/div
script
consttime=3000;
//自动播放速度
varindex=0
//索引
constswiperitem=document.getElementById('swiper')//获取父元素
constswiper=swiperitem.getElementsByTagName('div')//获取合集
//
自动轮播
varsetTime=setInterval(()={
if(indexswiper.length-1){
index++
}else{
index=0
}
style()
},time)
//点解切换
for(leti=0;iswiper.length;i++){
swiper[i].onclick=function(){
if(i===index)return
index=i
style()
}
}
//鼠标移入暂停
swiperitem.onmouseover
=function(){
clearInterval(setTime)
}
//鼠标移出继续轮播
swiperitem.onmouseout
=function(){
setTime=setInterval(()={
if(indexswiper.length-1){
index++
}else{
index=0
}
style()
},time)
}
//滚动事件
functionstyle(){
console.log(index)
for(leti=0;iswiper.length;i++){
swiper[i].className='swiper-timedd'
}
if(index===swiper.length-1){
swiper[index].className='swiper-timeb'
swiper[0].className='swiper-timea'
swiper[index-1].className='swiper-timec'
}elseif(index===0){
swiper[index].className='swiper-timeb'
swiper[index+1].className='swiper-timea'
swiper[swiper.length-1].className='swiper-timec'
}
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 沉降罐培训课件
- 护理健康教育小组总结
- 急性心肌梗死疑难病例
- 2025年四川省广元市旺苍县四模物理考前练习卷
- 2025年版N1叉车司机考试内部培训模拟题库附答案必考点
- 2024年浙江省安吉县人民医院公开招聘医务工作人员试题带答案详解
- 2024年湖南省隆回县邮政公开招聘工作人员试题带答案详解
- 2024年陕西省武功县人民医院公开招聘医务工作人员试题带答案详解
- 2024年黑龙江省兰西县邮政公开招聘工作人员试题带答案详解
- 2024年陕西省澄城县人民医院公开招聘医务工作人员试题带答案详解
- 财务共享公司建设方案
- 小学数学-二年级升三年级暑假数学作业-口算 +竖式计算
- 2025年陕西延长石油招聘笔试备考题库(带答案详解)
- 新版标准日本语初级上册课文(附中文对照)-日本初级课本
- 监督执纪工作规则
- 区块链技术及应用PPT完整全套教学课件
- 亲社会倾向量表(26题版)
- 河北尾矿库闭库工程施工组织设计
- 财务部安全隐患自查表
- GB/T 14260-2010散装重有色金属浮选精矿取样、制样通则
- GB/T 1048-2019管道元件公称压力的定义和选用
评论
0/150
提交评论