亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js+css實現卡片輪播圖效果

 更新時間:2022年02月23日 09:37:49   作者:little_shallot  
這篇文章主要為大家詳細介紹了js+css實現卡片輪播圖效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了js+css實現卡片輪播圖效果的具體代碼,供大家參考,具體內容如下

實現點擊的時候切換卡片,自動輪播,鼠標移入暫停,移出繼續(xù)輪播,有動畫事件
效果就是這樣

下面是代碼

<html lang="en">

<head>
? ? <meta charset="UTF-8">
? ? <meta http-equiv="X-UA-Compatible" content="IE=edge">
? ? <meta name="viewport" content="width=device-width, initial-scale=1.0">
? ? <title>Document</title>
? ? <style>
? ? ? ? .box {
? ? ? ? ? ? width: 680px;
? ? ? ? ? ? padding: 50px;
? ? ? ? ? ? margin: auto;
? ? ? ? ? ? margin-top: 300px;
? ? ? ? }

? ? ? ? .swiper,
? ? ? ? #swiper {
? ? ? ? ? ? width: 830px;
? ? ? ? ? ? height: 200px;
? ? ? ? ? ? position: relative;
? ? ? ? }

? ? ? ? .swiper div {
? ? ? ? ? ? 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;

? ? ? ? }

? ? ? ? .swiper div:nth-child(1) {
? ? ? ? ? ? background: #1ebe09;
? ? ? ? }

? ? ? ? .swiper div:nth-child(2) {
? ? ? ? ? ? background: #323a31;
? ? ? ? }

? ? ? ? .swiper div:nth-child(3) {
? ? ? ? ? ? background: #0985be;
? ? ? ? }

? ? ? ? .swiper div:nth-child(4) {
? ? ? ? ? ? background: #090cbe;
? ? ? ? }

? ? ? ? .swiper div:nth-child(5) {
? ? ? ? ? ? background: #be5109;
? ? ? ? }

? ? ? ? .swiper div:nth-child(6) {
? ? ? ? ? ? background: #be09af;
? ? ? ? }

? ? ? ? .swiper div:nth-child(7) {
? ? ? ? ? ? background: #be8e09;
? ? ? ? }

? ? ? ? .swiper div:nth-child(8) {
? ? ? ? ? ? background: #be0909;
? ? ? ? }

? ? ? ? .swiper div: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: below 10px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(30%, transparent), to(rgba(250, 250, 250, 0.3)));
? ? ? ? }

? ? ? ? .swiper .b {
? ? ? ? ? ? opacity: 1;
? ? ? ? ? ? z-index: 33;
? ? ? ? ? ? -webkit-box-reflect: below 10px -webkit-gradient(linear, left top, left bottom, 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: below 10px -webkit-gradient(linear, left top, left bottom, 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 class="box">
? ? ? ? <div class="swiper" id="swiper">
? ? ? ? ? ? <div class="swiper-time b">1</div>
? ? ? ? ? ? <div class="swiper-time a">2</div>
? ? ? ? ? ? <div class="swiper-time dd">3</div>
? ? ? ? ? ? <div class="swiper-time dd">4</div>
? ? ? ? ? ? <div class="swiper-time dd">5</div>
? ? ? ? ? ? <div class="swiper-time dd">6</div>
? ? ? ? ? ? <div class="swiper-time dd">7</div>
? ? ? ? ? ? <div class="swiper-time dd">8</div>
? ? ? ? ? ? <div class="swiper-time c">9</div>

? ? ? ? </div>
? ? </div>
? ? <script>
? ? ? ? const time = 3000 ; ?//自動播放速度
? ? ? ? var index = 0 ?// 索引
? ? ? ? const swiperitem = document.getElementById('swiper') //獲取父元素
? ? ? ? const swiper = swiperitem.getElementsByTagName('div') //獲取合集
? ? ? ? ? ? ? ? // ? ?自動輪播
? ? ? ? var setTime = setInterval(() => {
? ? ? ? ? ? if (index < swiper.length-1) {
? ? ? ? ? ? ? ? index++
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? index = 0
? ? ? ? ? ? }
? ? ? ? ? ? style()
? ? ? ? }, time)
? ? ? ? // 點解切換
? ? ? ? for (let i = 0; i < swiper.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 (index < swiper.length-1) {
? ? ? ? ? ? ? ? ? ? index++
? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? index = 0
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? style()
? ? ? ? ? ? }, time)
? ? ? ? }
? ? ? ? // 滾動事件
? ? ? ? function style() {
? ? ? ? ? ? console.log(index)
? ? ? ? ? ? for (let i = 0; i < swiper.length; i++) {
? ? ? ? ? ? ? ? swiper[i].className = 'swiper-time dd'
? ? ? ? ? ? }
? ? ? ? ? ? if (index === swiper.length - 1) {
? ? ? ? ? ? ? ? swiper[index].className = 'swiper-time b'
? ? ? ? ? ? ? ? swiper[0].className = 'swiper-time a'
? ? ? ? ? ? ? ? swiper[index - 1].className = 'swiper-time c'
? ? ? ? ? ? } else if (index === 0) {
? ? ? ? ? ? ? ? swiper[index].className = 'swiper-time b'
? ? ? ? ? ? ? ? swiper[index + 1].className = 'swiper-time a'
? ? ? ? ? ? ? ? swiper[swiper.length - 1].className = 'swiper-time c'
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? swiper[index].className = 'swiper-time b'
? ? ? ? ? ? ? ? swiper[index + 1].className = 'swiper-time a'
? ? ? ? ? ? ? ? swiper[index - 1].className = 'swiper-time c'
? ? ? ? ? ? }
? ? ? ? }

? ? </script>
</body>

</html>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • 深入理解Javascript里的依賴注入

    深入理解Javascript里的依賴注入

    我喜歡引用這句話,“程序是對復雜性的管理”。計算機世界是一個巨大的抽象建筑群。我們簡單的包裝一些東西然后發(fā)布新工具,周而復始。現在思考下,你所使用的語言包括的一些內建的抽象函數或是低級操作符。這在JavaScript里是一樣的
    2014-03-03
  • javascript下function聲明一些小結

    javascript下function聲明一些小結

    function聲明一些東西,我們都知道function和var一樣是預處理的在js里面,但是到底什么是函數聲明呢,我們來看幾個例子
    2007-12-12
  • bootstrap3使用bootstrap datetimepicker日期插件

    bootstrap3使用bootstrap datetimepicker日期插件

    這篇文章主要為大家詳細介紹了bootstrap3中使用bootstrap datetimepicker日期插件的用法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • js實現(全選)多選按鈕的方法【附實例】

    js實現(全選)多選按鈕的方法【附實例】

    下面小編就為大家?guī)硪黄猨s實現(全選)多選按鈕的方法【附實例】。小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-03-03
  • Javascript和jQuery的深淺拷貝詳解

    Javascript和jQuery的深淺拷貝詳解

    這篇文章主要為大家詳細介紹了Javascript和jQuery的深淺拷貝,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • JavaScript中發(fā)出HTTP請求最常用的方法

    JavaScript中發(fā)出HTTP請求最常用的方法

    JavaScript具有很好的模塊和方法來發(fā)送可用于從服務器端資源發(fā)送或接收數據的HTTP請求。這篇文章主要介紹了JavaScript中發(fā)出HTTP請求最常用的方法,需要的朋友可以參考下
    2018-07-07
  • JavaScript實現鼠標滑過處生成氣泡的方法

    JavaScript實現鼠標滑過處生成氣泡的方法

    這篇文章主要介紹了JavaScript實現鼠標滑過處生成氣泡的方法,涉及鼠標事件與頁面樣式的相關操作技巧,需要的朋友可以參考下
    2015-05-05
  • 微信小程序授權獲取用戶詳細信息openid的實例詳解

    微信小程序授權獲取用戶詳細信息openid的實例詳解

    這篇文章主要介紹了微信小程序授權獲取用戶詳細信息openid的實例詳解的相關資料,希望通過本文能幫助到大家,需要的朋友可以參考下
    2017-09-09
  • js實現隨機點名系統(tǒng)(實例講解)

    js實現隨機點名系統(tǒng)(實例講解)

    下面小編就為大家?guī)硪黄猨s實現隨機點名系統(tǒng)(實例講解)。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • location.hash保存頁面狀態(tài)的技巧

    location.hash保存頁面狀態(tài)的技巧

    hash 屬性是一個可讀可寫的字符串,該字符串是 URL 的錨部分(從 # 號開始的部分)。接下來通過本文給大家介紹location.hash保存頁面狀態(tài)的相關內容,感興趣的朋友一起學習吧
    2016-04-04

最新評論