欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡單的漸變輪播插件

 更新時間:2017年01月12日 15:13:19   作者:Creabine  
本文主要介紹了簡單的漸變輪播插件,具有一定的參考價值,下面跟著小編一起來看下吧

話不多說,請看代碼:

<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Example</title>
    <style>
.CreabineCarousel{
 width: 100%;
  height: 700px;
  background-size: cover;
  position: relative;
}
.CreabineCarousel .CreabineCarousel-dotContainer{
 position:absolute;
 bottom: 5%;
 margin:0 auto;
 z-index: 100;
 list-style-type: none;
 width: 100%;
 text-align: center;
 left: 0;
 padding: 0;
}
.CreabineCarousel .CreabineCarousel-dotContainer .dot{
 width: 30px;
 height: 4px;
 border-radius:3px;
 background-color:#fff;
 display: inline-block;
 margin:0 5px;
 opacity: 0.7;
}
.CreabineCarousel .CreabineCarousel-dotContainer .dot:hover{
 opacity: 1;
}
.CreabineCarousel .CreabineCarousel-item{
 position:absolute;
 width: 100%;
 height: 100%;
 transition:all 0.8s;
}
.CreabineCarousel .CreabineCarousel-item h1{
 max-width: 600px;
 text-align: center;
 font-size: 5rem;
 line-height: 1.3;
 color: #fff;
 padding: 300px 50px 0 50px;
 margin:0 auto;
}
.CreabineCarousel .CreabineCarousel-item p{
 max-width: 600px;
 text-align: center;
 font-size: 1.4rem;
 line-height: 1.4;
 color: #fff;
 padding-top: 10px 50px 0 50px;
 margin:0 auto;
}
    </style>
</head>
<body>
 <div id="carouselRoot"></div>
<script>
function CreabineCarousel(options){
 var imgPathList = options.images;
  var textList = options.contant;
  if (!options.root) {
    throw "require root to this CreabineCarousel";
  }
  if (!imgPathList) {
    throw "must provide parameter images";
  }
  if (imgPathList.length != textList.length) {
    throw "images are not equal to contants";
  }
  var changeCount = 0;
  var timer;
  var _autoScroll = options.autoScroll || false;
  var _scrollDuration = options.scrollDuration || 4000;
  var _height = options.height || 700;

  function initElements() {
   var _root = document.getElementById(options.root);
   if (!_root) {
      throw "no exist called this name element,please create element called this name";
    }
    _root.className = "CreabineCarousel";
    _root.style.height = _height + "px";
    var _dotContainer = document.createElement("ul");
    _dotContainer.className = 'CreabineCarousel-dotContainer';
    _root.appendChild(_dotContainer);
    for (var i = 0; i < imgPathList.length; i++) {
      var _dot = document.createElement("li");
      _dot.className = "dot";
      _dot.id = "item" + (i+1) + "dot";
      _dotContainer.appendChild(_dot);
      var _item = document.createElement("div");
      _item.className = "CreabineCarousel-item"
      _item.id = "item" + (i+1);
      _item.style.backgroundImage = "url(" + imgPathList[i] + ")";
      _item.style.backgroundSize = "cover";
      _item.style.backgroundRepeat = "no-repeat";
      if(i == 0){
        _item.style.opacity = '0';
        _item.style.zIndex = '1';
      }
      _root.appendChild(_item);
      var _h = document.createElement("h1");
      _h.innerText = textList[i].title;
      _item.appendChild(_h);
      var _p = document.createElement("p");
      _p.innerText = textList[i].text;
      _item.appendChild(_p);
    }
    _dotContainer.addEventListener("mouseover",function(e){
     if( e.target && e.target.className == "dot" ){
     clearInterval(timer);
     var id = e.target.id.substring(0,5);
     CarouselHover(id);
     }
    });
    _dotContainer.addEventListener("mouseout",function(e){
     if( e.target && e.target.className == "dot" ){
     var id = e.target.id;
     CarouselOut(id);
     }
    });
    if(_autoScroll){
      timer = setInterval(function(){Carousel()},_scrollDuration);
    }
  }
  function Carousel(){
    var all = document.getElementsByClassName('CreabineCarousel-item');
    for (var i = all.length - 1; i >= 0; i--) {
      all[i].style.opacity = '0';
      all[i].style.zIndex = '1';
    }
    var i=((changeCount++%5)+1);
    var id = "item" + i;
    document.getElementById(id).style.opacity = '1';
    document.getElementById(id).style.zIndex = '10';
  }
  function CarouselHover(id){
    clearInterval(timer);
    var all = document.getElementsByClassName('CreabineCarousel-item');
    for (var i = all.length - 1; i >= 0; i--) {
      all[i].style.opacity = '0';
      all[i].style.zIndex = '1';
    }
    document.getElementById(id).style.opacity = '1';
    document.getElementById(id).style.zIndex = '10';
  }
  function CarouselOut(id){
    var num = id.substring(4,5);
    num = parseInt(num)-1;
    changeCount = num;
    timer = window.setInterval(function(){Carousel()},_scrollDuration);
  }
  initElements();
 new CreabineCarousel({
 root:'carouselRoot',
 autoScroll:true,
        scrollDuration:3000,
 height:700,
 images:['https://cdn.worktile.com/images/index/index_all_bg_1.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_2.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_3.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_4.jpg?v=4.5.18','https://cdn.worktile.com/images/index/index_all_bg_5.jpg?v=4.5.18'],
 contant:[
  {
  title:"title-1",
  text:"text-111"
  },
  {
  title:"title-2",
  text:"text-222"
  },
  {
  title:"title-3",
  text:"text-333"
  },
  {
  title:"title-4",
  text:"text-444"
  },
  {
  title:"title-5",
  text:"text-555"
  },
 ]
 });
</script>
</body>
</html>

以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!

相關文章

  • 基于js 本地存儲(詳解)

    基于js 本地存儲(詳解)

    下面小編就為大家?guī)硪黄趈s 本地存儲(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-08-08
  • 如何在微信小程序中實現(xiàn)Mixins方案

    如何在微信小程序中實現(xiàn)Mixins方案

    這篇文章主要給大家介紹了關于如何在微信小程序中實現(xiàn)Mixins方案的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用微信小程序具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-06-06
  • 你不知道的 TypeScript 高級類型(小結)

    你不知道的 TypeScript 高級類型(小結)

    這篇文章主要介紹了你不知道的 TypeScript 高級類型(小結),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-08-08
  • 基于JS判斷iframe是否加載成功的方法(多種瀏覽器)

    基于JS判斷iframe是否加載成功的方法(多種瀏覽器)

    這篇文章主要介紹了基于JS判斷iframe是否加載成功的方法【多種瀏覽器】的相關資料,需要的朋友可以參考下
    2016-05-05
  • Firefox中beforeunload事件的實現(xiàn)缺陷淺析

    Firefox中beforeunload事件的實現(xiàn)缺陷淺析

    beforeunload 指在頁面卸載前提供的最后一次JS執(zhí)行的機會
    2012-05-05
  • 常用簡易JavaScript函數(shù)

    常用簡易JavaScript函數(shù)

    返回字符串的字節(jié)長度 檢查表單是否符合規(guī)定的長度 等表達驗證函數(shù)
    2009-04-04
  • JS數(shù)組方法reduce的用法實例分析

    JS數(shù)組方法reduce的用法實例分析

    這篇文章主要介紹了JS數(shù)組方法reduce的用法,結合實例形式詳細分析了JS數(shù)組方法reduce的基本功能、使用方法及相關操作注意事項,需要的朋友可以參考下
    2020-03-03
  • js實現(xiàn)點擊煙花特效

    js實現(xiàn)點擊煙花特效

    這篇文章主要介紹了js實現(xiàn)點擊煙花特效,幫助大家更好的利用js美化網(wǎng)頁,感興趣的朋友可以了解下
    2020-10-10
  • 基于JavaScript實現(xiàn)購物網(wǎng)站商品放大鏡效果

    基于JavaScript實現(xiàn)購物網(wǎng)站商品放大鏡效果

    大家在日常生活中都有網(wǎng)購的經驗,有的網(wǎng)站會有商品放大鏡功能,效果非常棒,那么基于js代碼是如何實現(xiàn)的呢?下面小編給大家?guī)砹嘶趈s實現(xiàn)購物網(wǎng)站商品放大鏡效果,非常不錯,感興趣的朋友參考下吧
    2016-09-09
  • JS控制文本域只讀或可寫屬性的方法

    JS控制文本域只讀或可寫屬性的方法

    這篇文章主要介紹了JS控制文本域只讀或可寫屬性的方法,涉及javascript針對頁面元素屬性的動態(tài)操作技巧,需要的朋友可以參考下
    2016-06-06

最新評論