本文實例講述了jQuery實現自動輪播旋轉木馬特效。分享給大家供大家參考。具體如下:
這是一款基於jQuery實作自動輪播旋轉木馬特效程式碼,實作過程很簡單。
運作效果圖: -------------------檢視效果 下載來源碼-------------------
簡要教學
jquery.caroursel.js是一款非常實用的可自動輪播的jQuery旋轉木馬插件。這張旋轉木馬將圖片進行堆疊,輪流的將圖片推送到最前面來展示,形成旋轉木馬的效果。
使用方法
此jQuery旋轉木馬插件需要引進jQuery,jquery.carousel.js檔。
<script src="js/jquery.min.js"></script> <script src="js/jquery.carousel.js"></script>
HTML結構
這個jQuery旋轉木馬外掛程式使用一個
<div class="caroursel rotator-demo"> <ul class="rotator-list"> <li class="rotator-item"><img src="/static/imghwm/default1.png" data-src="image/1.jpg" class="lazy" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class="rotator-item"><img src="/static/imghwm/default1.png" data-src="image/2.jpg" class="lazy" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class="rotator-item"><img src="/static/imghwm/default1.png" data-src="image/3.jpg" class="lazy" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> </ul> <div class="rotator-btn rotator-prev-btn"></div> <div class="rotator-btn rotator-next-btn"></div> </div>
圖片的數量需要為奇數張,否則顯示會有一些異常,這是該插件的一個小bug。
CSS樣式
你需要為該旋轉木馬特效添加下面的一些必要的CSS樣式。
.rotator-main { position: relative; width: 900px; height: 400px } .rotator-main a, .rotator-main img { display: block; } .rotator-main .rotator-list { width: 900px; height: 400px } .rotator-main .rotator-list .rotator-item { position: absolute; left: 0px; top: 0px } .rotator-main .rotator-btn { position: absolute; height: 100%; width: 100px; top: 0px; z-index: 10; opacity: 0; } .rotator-main .rotator-prev-btn { left: 0px; background: url("../image/btn_l.png") no-repeat center center; background-color: red } .rotator-main .rotator-next-btn { right: 0px; background: url("../image/btn_r.png") no-repeat center center; background-color: red }
初始化外掛程式
在頁面DOM元素載入完畢之後,可以透過下面的方法來初始化該旋轉木馬外掛程式。
Caroursel.init($('.caroursel'))
如果你需要自訂一些參數,可以在頂層
<div class="caroursel rotator-main" data-setting = '{ "width":1000, //旋转木马的宽度 "height":270, //旋转木马的高度 "posterWidth":640, //当前显示的图片的宽度 "posterHeight":270, //当前显示的图片的高度 "scale":0.8, //缩放值 "algin":"middle", //对齐方式 "speed":"1000", //动画速度 "isAutoplay":"true", //自动播放 "dealy":"1000" //延迟时间 }'>
為大家分享的jQuery實作自動輪播旋轉木馬特效程式碼如下
<html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>jQuery自动轮播旋转木马插件</title> <link rel="stylesheet" type="text/css" href="css/normalize.css" /> <link rel="stylesheet" type="text/css" href="css/default.css"> <link type="text/css" rel="stylesheet" href="css/carousel.css"> <style type="text/css"> .caroursel{margin:150px auto;} </style> <!--[if IE]> <script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script> <![endif]--> </head> <body> <article class="htmleaf-container"> <header class="htmleaf-header"> <h1 id="jQuery自动轮播旋转木马插件">jQuery自动轮播旋转木马插件</h1> </header> <div class = "caroursel poster-main" data-setting = '{ "width":1000, "height":270, "posterWidth":640, "posterHeight":270, "scale":0.8, "dealy":"2000", "algin":"middle" }'> <ul class = "poster-list"> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/1.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/2.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/3.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/4.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/5.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/6.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> <li class = "poster-item"><img src="/static/imghwm/default1.png" data-src="image/1.jpg" class="lazy" width = "100%" style="max-width:90%" alt="基於jQuery實作自動輪播旋轉木馬特效_jquery" ></li> </ul> <div class = "poster-btn poster-prev-btn"></div> <div class = "poster-btn poster-next-btn"></div> </div> </article> <script>window.jQuery || document.write('<script src="js/jquery-2.1.1.min.js"><\/script>')</script> <script src="js/jquery.carousel.js"></script> <script> Caroursel.init($('.caroursel')) </script> </body> </html>

JavaScript核心數據類型在瀏覽器和Node.js中一致,但處理方式和額外類型有所不同。 1)全局對像在瀏覽器中為window,在Node.js中為global。 2)Node.js獨有Buffer對象,用於處理二進制數據。 3)性能和時間處理在兩者間也有差異,需根據環境調整代碼。

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python和JavaScript的主要區別在於類型系統和應用場景。 1.Python使用動態類型,適合科學計算和數據分析。 2.JavaScript採用弱類型,廣泛用於前端和全棧開發。兩者在異步編程和性能優化上各有優勢,選擇時應根據項目需求決定。

選擇Python還是JavaScript取決於項目類型:1)數據科學和自動化任務選擇Python;2)前端和全棧開發選擇JavaScript。 Python因其在數據處理和自動化方面的強大庫而備受青睞,而JavaScript則因其在網頁交互和全棧開發中的優勢而不可或缺。

Python和JavaScript各有優勢,選擇取決於項目需求和個人偏好。 1.Python易學,語法簡潔,適用於數據科學和後端開發,但執行速度較慢。 2.JavaScript在前端開發中無處不在,異步編程能力強,Node.js使其適用於全棧開發,但語法可能複雜且易出錯。

javascriptisnotbuiltoncorc; sanInterpretedlanguagethatrunsonenginesoftenwritteninc.1)JavascriptwasdesignedAsignedAsalightWeight,drackendedlanguageforwebbrowsers.2)Enginesevolvedfromsimpleterterpretpretpretpretpreterterpretpretpretpretpretpretpretpretpretcompilerers,典型地,替代品。

JavaScript可用於前端和後端開發。前端通過DOM操作增強用戶體驗,後端通過Node.js處理服務器任務。 1.前端示例:改變網頁文本內容。 2.後端示例:創建Node.js服務器。

選擇Python還是JavaScript應基於職業發展、學習曲線和生態系統:1)職業發展:Python適合數據科學和後端開發,JavaScript適合前端和全棧開發。 2)學習曲線:Python語法簡潔,適合初學者;JavaScript語法靈活。 3)生態系統:Python有豐富的科學計算庫,JavaScript有強大的前端框架。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

WebStorm Mac版
好用的JavaScript開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版
中文版,非常好用

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境