




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第js+css實(shí)現(xiàn)卡片輪播圖效果本文實(shí)例為大家分享了js+css實(shí)現(xiàn)卡片輪播圖效果的具體代碼,供大家參考,具體內(nèi)容如下
實(shí)現(xiàn)點(diǎn)擊的時(shí)候切換卡片,自動(dòng)輪播,鼠標(biāo)移入暫停,移出繼續(xù)輪播,有動(dòng)畫(huà)事件
效果就是這樣
下面是代碼
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;
//自動(dòng)播放速度
varindex=0
//索引
constswiperitem=document.getElementById('swiper')//獲取父元素
constswiper=swiperitem.getElementsByTagName('div')//獲取合集
//
自動(dòng)輪播
varsetTime=setInterval(()={
if(indexswiper.length-1){
index++
}else{
index=0
}
style()
},time)
//點(diǎn)解切換
for(leti=0;iswiper.length;i++){
swiper[i].onclick=function(){
if(i===index)return
index=i
style()
}
}
//鼠標(biāo)移入暫停
swiperitem.onmouseover
=function(){
clearInterval(setTime)
}
//鼠標(biāo)移出繼續(xù)輪播
swiperitem.onmouseout
=function(){
setTime=setInterval(()={
if(indexswiper.length-1){
index++
}else{
index=0
}
style()
},time)
}
//滾動(dòng)事件
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《幼兒園教育基礎(chǔ)》電子教案-第1單元
- 宏志助航計(jì)劃就業(yè)能力培訓(xùn)體系
- 美團(tuán)招聘文員培訓(xùn)
- 《托育服務(wù)政策法規(guī)與職業(yè)倫理》課件-第五章
- 《論甲午海戰(zhàn)談》課件
- 獨(dú)立結(jié)算協(xié)議書(shū)
- 達(dá)人經(jīng)濟(jì)代理合同協(xié)議
- 校園環(huán)保協(xié)議書(shū)
- 車位廠房轉(zhuǎn)讓合同協(xié)議
- 河壩合同協(xié)議書(shū)
- 2025網(wǎng)絡(luò)安全協(xié)議合同
- 混凝土考試試題及答案
- 廣東2025年廣東省生物制品與藥物研究所招聘12人筆試歷年參考題庫(kù)附帶答案詳解
- 2024北京西城區(qū)五年級(jí)(下)期末英語(yǔ)試題及答案
- 《古埃及文明》課件
- 歷屆全國(guó)初中應(yīng)用物理知識(shí)競(jìng)賽匯編
- 國(guó)企筆試招聘題目
- 醫(yī)院培訓(xùn)課件:《西門子Syngo.via工作站的臨床應(yīng)用》
- 企業(yè)刑事合規(guī)培訓(xùn)課件
- 訂做門合同協(xié)議范本
- 2025年新版《保障中小企業(yè)款項(xiàng)支付條例》解讀學(xué)習(xí)課件
評(píng)論
0/150
提交評(píng)論