話不多說,請(qǐng)看代碼:
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供敦化網(wǎng)站建設(shè)、敦化做網(wǎng)站、敦化網(wǎng)站設(shè)計(jì)、敦化網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、敦化企業(yè)網(wǎng)站模板建站服務(wù),10年敦化做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。<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 h2{ 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("h2"); _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://cache.yisu.com/upload/information/20200622/114/78072.jpg?v=4.5.18','https://cache.yisu.com/upload/information/20200622/114/78073.jpg?v=4.5.18','https://cache.yisu.com/upload/information/20200622/114/78074.jpg?v=4.5.18','https://cache.yisu.com/upload/information/20200622/114/78075.jpg?v=4.5.18','https://cache.yisu.com/upload/information/20200622/114/78076.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>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站jinyejixie.com,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)站欄目:簡(jiǎn)單的漸變輪播插件-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://jinyejixie.com/article20/deopjo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、企業(yè)建站、關(guān)鍵詞優(yōu)化、品牌網(wǎng)站制作、品牌網(wǎng)站建設(shè)、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容