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

基于jQuery實(shí)現(xiàn)自動輪播旋轉(zhuǎn)木馬特效

 更新時(shí)間:2015年11月02日 10:47:26   投稿:lijiao  
這篇文章主要介紹了基于jQuery實(shí)現(xiàn)自動輪播旋轉(zhuǎn)木馬特效,圖片輪播效果特別適合做產(chǎn)品展示,感興趣的小伙伴可以參考下。

本文實(shí)例講述了jQuery實(shí)現(xiàn)自動輪播旋轉(zhuǎn)木馬特效。分享給大家供大家參考。具體如下:
這是一款基于jQuery實(shí)現(xiàn)自動輪播旋轉(zhuǎn)木馬特效代碼,實(shí)現(xiàn)過程很簡單。
運(yùn)行效果圖:           -------------------查看效果 下載源碼-------------------

簡要教程
jquery.caroursel.js是一款非常實(shí)用的可自動輪播的jQuery旋轉(zhuǎn)木馬插件。該旋轉(zhuǎn)木馬將圖片進(jìn)行堆疊,輪流的將圖片推送到最前面來展示,形成旋轉(zhuǎn)木馬的效果。
 使用方法
該jQuery旋轉(zhuǎn)木馬插件需要引入jQuery,jquery.carousel.js文件。

<script src="js/jquery.min.js"></script>
<script src="js/jquery.carousel.js"></script>    

HTML結(jié)構(gòu)

該jQuery旋轉(zhuǎn)木馬插件使用一個(gè)<div>來作為包裹元素,在它里面是一個(gè)無序列表,用于放置圖片,以及兩個(gè)作為前后導(dǎo)航按鈕的<div>元素。

<div class="caroursel rotator-demo">
 <ul class="rotator-list">
 <li class="rotator-item"><img src="image/1.jpg"></li>
 <li class="rotator-item"><img src="image/2.jpg"></li>
 <li class="rotator-item"><img src="image/3.jpg"></li>
 </ul>
 <div class="rotator-btn rotator-prev-btn"></div>
 <div class="rotator-btn rotator-next-btn"></div>
</div>    

圖片的數(shù)量需要為奇數(shù)張,否則顯示會有一些異常,這是該插件的一個(gè)小bug。
CSS樣式

你需要為該旋轉(zhuǎn)木馬特效添加下面的一些必要的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元素加載完畢之后,可以通過下面的方法來初始化該旋轉(zhuǎn)木馬插件。
Caroursel.init($('.caroursel'))               
如果你需要自定義一些參數(shù),可以在頂層<div>元素中設(shè)置data-setting屬性。

<div class="caroursel rotator-main"
  data-setting = '{
  "width":1000,   //旋轉(zhuǎn)木馬的寬度
  "height":270,   //旋轉(zhuǎn)木馬的高度
  "posterWidth":640, //當(dāng)前顯示的圖片的寬度
  "posterHeight":270, //當(dāng)前顯示的圖片的高度
  "scale":0.8,   //縮放值
  "algin":"middle",  //對齊方式
  "speed":"1000",  //動畫速度
  "isAutoplay":"true", //自動播放
  "dealy":"1000"  //延遲時(shí)間
}'>    

小提示:瀏覽器中如果不能正常運(yùn)行,可以嘗試切換瀏覽模式。
為大家分享的jQuery實(shí)現(xiàn)自動輪播旋轉(zhuǎn)木馬特效代碼如下

<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自動輪播旋轉(zhuǎn)木馬插件</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>jQuery自動輪播旋轉(zhuǎn)木馬插件</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="image/1.jpg" width = "100%" height="100%"></li>
  <li class = "poster-item"><img src="image/2.jpg" width = "100%" height="100%"></li>
  <li class = "poster-item"><img src="image/3.jpg" width = "100%" height="100%"></li>
  <li class = "poster-item"><img src="image/4.jpg" width = "100%" height="100%"></li>
  <li class = "poster-item"><img src="image/5.jpg" width = "100%" height="100%"></li>
  <li class = "poster-item"><img src="image/6.jpg" width = "100%" height="100%"></li>
  <li class = "poster-item"><img src="image/1.jpg" width = "100%" height="100%"></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>

為大家分享的jQuery實(shí)現(xiàn)自動輪播旋轉(zhuǎn)木馬特效代碼,希望大家可以喜歡,并應(yīng)用到實(shí)踐中。

相關(guān)文章

最新評論