




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
第js+css實現(xiàn)卡片輪播圖效果本文實例為大家分享了js+css實現(xiàn)卡片輪播圖效果的具體代碼,供大家參考,具體內(nèi)容如下
實現(xiàn)點擊的時候切換卡片,自動輪播,鼠標移入暫停,移出繼續(xù)輪播,有動畫事件
效果就是這樣
下面是代碼
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)
}
//鼠標移出繼續(xù)輪播
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 橋隧工中級練習題及答案(附解析)
- 2024年工業(yè)廢水中級模擬考試題(附答案解析)
- 2023年6月美容師初級練習題與答案(附解析)
- 稀土金屬壓延加工的殘余應力分析考核試卷
- 節(jié)能技術項目在鋼鐵行業(yè)的節(jié)能減排措施考核試卷
- 電池制造中的工業(yè)應用與能源儲存技術考核試卷
- 2025年其他未列明電子設備項目合作計劃書
- 2025年熱固化油墨項目發(fā)展計劃
- 經(jīng)濟型酒店業(yè)客戶體驗優(yōu)化考核試卷
- 聚苯并噁唑改性纖維制備考核試卷
- (高清版)JTGT 3650-01-2022 公路橋梁施工監(jiān)控技術規(guī)程
- 中國歷史地理智慧樹知到期末考試答案章節(jié)答案2024年北京大學
- MOOC 跨文化交際通識通論-揚州大學 中國大學慕課答案
- 常見典型心電圖診斷規(guī)培-課件
- 華中科技大學碩士學位論文答辯評審表(自然科學類)
- 六年級下冊英語素材全冊單詞表 牛津上海版
- 費森4008s常見故障排除
- 積極心態(tài)與消極心態(tài)
- 《土地寶懺》2019版定稿
- 越王勾踐劍PPT課件
- 防溺水大家訪記錄表
評論
0/150
提交評論