基于jQuery實現多種樣式幻燈片切換特效



45 179 60



特效描述:基于jQuery實現 多種樣式 幻燈片切換,基于jQuery實現多種樣式幻燈片切換特效

代碼結構

1. 引入CSS

<link rel="stylesheet" href="css/monokai.min.css">
<link rel="stylesheet" type="text/css" href="slick/slick.css"/>
<link rel="stylesheet" type="text/css" href="css/style.css">

2. 引入JS

<script src="js/modernizr.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="js/highlight.min.js"></script>
<script type="text/javascript" src="slick/slick.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>

3. HTML代碼

		<section id="features" class="blue">
			<div class="content">
				<h2>Single Item</h2>
				<div class="slider single-item">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
				</div>
				<pre><code>
$('.single-item').slick();
				</code></pre>
				<hr/>
				<h2>Multiple Items</h2>
				<div class="slider multiple-items">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
					<div><h3>7</h3></div>
					<div><h3>8</h3></div>
					<div><h3>9</h3></div>
				</div>
				<pre><code>
$('.multiple-items').slick({
  infinite: true,
  slidesToShow: 3,
  slidesToScroll: 3
});
				</code></pre>
				<hr/>
				<h2>Responsive Display</h2>
				<div class="slider responsive">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
					<div><h3>7</h3></div>
					<div><h3>8</h3></div>
				</div>
				<pre><code>
$('.responsive').slick({
  dots: true,
  infinite: false,
  speed: 300,
  slidesToShow: 4,
  slidesToScroll: 4,
  responsive: [
    {
      breakpoint: 1024,
      settings: {
        slidesToShow: 3,
        slidesToScroll: 3,
        infinite: true,
        dots: true
      }
    },
    {
      breakpoint: 600,
      settings: {
        slidesToShow: 2,
        slidesToScroll: 2
      }
    },
    {
      breakpoint: 480,
      settings: {
        slidesToShow: 1,
        slidesToScroll: 1
      }
    }
  ]
});
				</code></pre>
				<hr/>
				<h2>One At A Time</h2>
				<div class="slider one-time">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
				</div>
				<pre><code>
$('.one-time').slick({
  dots: true,
  infinite: false,
  speed: 300,
  slidesToShow: 5,
  touchMove: false,
  slidesToScroll: 1
});
				</code></pre>
				<hr/>
				<h2>Uneven Sets</h2>
				<div class="slider uneven">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
				</div>
				<pre><code>
$('.uneven').slick({
  slidesToShow: 4,
  slidesToScroll: 4
});
				</code></pre>
				<hr/>
				<h2>Center Mode</h2>
				<div class="slider center">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
				</div>
				<pre><code>
$('.center').slick({
  centerMode: true,
  centerPadding: '60px',
  slidesToShow: 3,
  responsive: [
    {
      breakpoint: 768,
      settings: {
        arrows: false,
        centerMode: true,
        centerPadding: '40px',
        slidesToShow: 3
      }
    },
    {
      breakpoint: 480,
      settings: {
        arrows: false,
        centerMode: true,
        centerPadding: '40px',
        slidesToShow: 1
      }
    }
  ]
});
				</code></pre>
				<hr/>
				<h2>Lazy Loading</h2>
				<div class="slider lazy">
					<div><div class="image"><img data-lazy="img/lazyfonz1.png"/></div></div>
					<div><div class="image"><img data-lazy="img/lazyfonz2.png"/></div></div>
					<div><div class="image"><img data-lazy="img/lazyfonz3.png"/></div></div>
					<div><div class="image"><img data-lazy="img/lazyfonz4.png"/></div></div>
					<div><div class="image"><img data-lazy="img/lazyfonz5.png"/></div></div>
					<div><div class="image"><img data-lazy="img/lazyfonz6.png"/></div></div>
				</div>
				<pre><code>
// To use lazy loading, set a data-lazy attribute
// on your img tags and leave off the src
&lt;img data-lazy="img/lazyfonz1.png"/&gt;
$('.lazy').slick({
  lazyLoad: 'ondemand',
  slidesToShow: 3,
  slidesToScroll: 1
});
				</code></pre>
				<hr/>
				<h2>Autoplay</h2>
				<div class="slider autoplay">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
				</div>
			<pre><code>
$('.autoplay').slick({
  slidesToShow: 3,
  slidesToScroll: 1,
  autoplay: true,
  autoplaySpeed: 2000,
});
				</code></pre>
				<hr/>
				<h2>Fade</h2>
				<div class="slider fade">
					<div><div class="image"><img src="img/fonz1.png"/></div></div>
					<div><div class="image"><img src="img/fonz2.png"/></div></div>
					<div><div class="image"><img src="img/fonz3.png"/></div></div>
				</div>
			<pre><code>
$('.fade').slick({
  dots: true,
  infinite: true,
  speed: 500,
  fade: true,
  slide: '> div',
  cssEase: 'linear'
});
				</code></pre>
				<hr/>
				<h2>Add & Remove</h2>
				<div class="slider add-remove">
					<div><h3>1</h3></div>
				</div>
				<div class="buttons">
					<a href="javascript:void(0)" class="button js-add-slide">Add Slide</a>
					<a href="javascript:void(0)" class="button js-remove-slide">Remove Slide</a>
				</div>
			<pre><code>
$('.add-remove').slick({
  slidesToShow: 3,
  slidesToScroll: 3
});
var slideIndex = 1;
$('.js-add-slide').on('click', function(){
  slideIndex++;
  $('.add-remove').slickAdd('&lt;div&gt;&lt;h3&gt;'+slideIndex+'&lt;/h3&gt;&lt;/div&gt;');
});
$('.js-remove-slide').on('click', function(){
  $('.add-remove').slickRemove(slideIndex - 1);
  slideIndex--;
});
				</code></pre>
				<hr/>
				<h2>Filtering</h2>
				<div class="slider filtering">
					<div><h3>1</h3></div>
					<div><h3>2</h3></div>
					<div><h3>3</h3></div>
					<div><h3>4</h3></div>
					<div><h3>5</h3></div>
					<div><h3>6</h3></div>
					<div><h3>7</h3></div>
					<div><h3>8</h3></div>
					<div><h3>9</h3></div>
					<div><h3>10</h3></div>
					<div><h3>11</h3></div>
					<div><h3>12</h3></div>
				</div>
				<div class="filter">
					<a href="javascript:void(0)" class="button js-filter">Filter Slides</a>
				</div>
			<pre><code>
$('.filtering').slick({
  slidesToShow: 4,
  slidesToScroll: 4
});
var filtered = false;
$('.js-filter').on('click', function(){
  if(filtered === false) {
    $('.filtering').slickFilter(':even');
    $(this).text('Unfilter Slides');
    filtered = true;
  } else {
    $('.filtering').slickUnfilter();
    $(this).text('Filter Slides');
    filtered = false;
  }
});
				</code></pre>
				<hr/>
				<h2>Destroy</h2>
				<p class="destroy">If you really want to be that guy...</p>
				<pre><code>
$('.your-slider').unslick();
				</code></pre>
				<h4 class="more">and a whole lot more...</h4>
				</div>
		</section>
		<section id="getting-started" class="white">
			<div class="content">
				<h2 class="margin-40">Getting Started</h2>
				<p>Set up your HTML.</p>
				<pre><code>
&lt;div class="your-class"&gt;
  &lt;div&gt;your content&lt;/div&gt;
  &lt;div&gt;your content&lt;/div&gt;
  &lt;div&gt;your content&lt;/div&gt;
&lt;/div&gt;
				</code></pre>
				<hr/>
				<p>Move the /slick folder into your project</p>
				<hr/>
				<p>Add slick.css in your &lt;head&gt;</p>
				<pre><code>
&lt;link rel="stylesheet" type="text/css" href="slick/slick.css"/&gt;
				</code></pre>
				<hr/>
				<p>Add slick.js before your closing &lt;body&gt; tag, after jQuery (requires jQuery 1.7 +)</p>
				<pre><code>
&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="slick/slick.min.js"&gt;&lt;/script&gt;
				</code></pre>
				<hr/>
				<p>Initialize your slider in your script file or an inline script tag</p>
				<pre><code>
$(document).ready(function(){
	$('.your-class').slick({
	  setting-name: setting-value
	});
});
				</code></pre>
			</div>
		</section>
		<section id="settings" class="blue">
			<div class="content">
				<h2 >Settings</h2>
				<table class="settings">
					<thead>
						<tr>
							<th class="first">Setting</th>
							<th class="type">Type</th>
							<th class="default">Default</th>
							<th class="last">Description</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>accessibility</td>
							<td>boolean</td>
							<td>true</td>
							<td>Enables tabbing and arrow key navigation</td>
						</tr>
						<tr>
							<td>autoplay</td>
							<td>boolean</td>
							<td>false</td>
							<td>Enables Autoplay</td>
						</tr>
						<tr>
							<td>autoplaySpeed</td>
							<td>int(ms)</td>
							<td>3000</td>
							<td>Autoplay Speed in milliseconds</td>
						</tr>
						<tr>
							<td>arrows</td>
							<td>boolean</td>
							<td>true</td>
							<td>Prev/Next Arrows</td>
						</tr>
						<tr>
							<td>centerMode</td>
							<td>boolean</td>
							<td>false</td>
							<td>Enables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts.</td>
						</tr>
						<tr>
							<td>centerPadding</td>
							<td>string</td>
							<td>'50px'</td>
							<td>Side padding when in center mode (px or %)</td>
						</tr>
						<tr>
							<td>cssEase</td>
							<td>string</td>
							<td>'ease'</td>
							<td>CSS3 Animation Easing</td>
						</tr>
						<tr>
							<td>customPaging</td>
							<td>function</td>
							<td>n/a</td>
							<td>Custom paging templates. See source for use example.</td>
						</tr>
						<tr>
							<td>dots</td>
							<td>boolean</td>
							<td>false</td>
							<td>Show dot indicators</td>
						</tr>
						<tr>
							<td>draggable</td>
							<td>boolean</td>
							<td>true</td>
							<td>Enable mouse dragging</td>
						</tr>
						<tr>
							<td>fade</td>
							<td>boolean</td>
							<td>false</td>
							<td>Enable fade</td>
						</tr>
						<tr>
							<td>easing</td>
							<td>string</td>
							<td>'linear'</td>
							<td>Add easing for jQuery animate. Use with easing libraries or default easing methods</td>
						</tr>
						<tr>
							<td>infinite</td>
							<td>boolean</td>
							<td>true</td>
							<td>Infinite loop sliding</td>
						</tr>
						<tr>
							<td>lazyLoad</td>
							<td>string</td>
							<td>'ondemand'</td>
							<td>Set lazy loading technique. Accepts 'ondemand' or 'progressive'.</td>
						</tr>
						<tr>
							<td>onBeforeChange</td>
					     <td>function</td>
							<td>null</td>
							<td>Before slide callback</td>
						</tr>
						<tr>
							<td>onAfterChange</td>
							<td>function</td>
							<td>null</td>
							<td>After slide callback</td>
						</tr>
						<tr>
							<td>onInit</td>
							<td>function</td>
							<td>null</td>
							<td>Callback that fires after first initialization</td>
						</tr>
						<tr>
							<td>onReInit</td>
							<td>function</td>
							<td>null</td>
							<td>Callback that fires after every re-initialization</td>
						</tr>
						<tr>
							<td>pauseOnHover</td>
							<td>boolean</td>
							<td>true</td>
							<td>Pause Autoplay On Hover</td>
						</tr>
						<tr>
							<td>responsive</td>
							<td>object</td>
							<td>none</td>
							<td>Object containing breakpoints and settings objects (see demo). Enables settings sets at given screen width.</td>
						</tr>
						<tr>
							<td>slide</td>
							<td>element</td>
							<td>'div'</td>
							<td>Element query to use as slide</td>
						</tr>
						<tr>
							<td>slidesToShow</td>
							<td>int</td>
							<td>1</td>
							<td># of slides to show</td>
						</tr>
						<tr>
							<td>slidesToScroll</td>
							<td>int</td>
							<td>1</td>
							<td># of slides to scroll</td>
						</tr>
						<tr>
							<td>speed</td>
							<td>int(ms)</td>
							<td>300</td>
							<td>Slide/Fade animation speed</td>
						</tr>
						<tr>
							<td>swipe</td>
							<td>boolean</td>
							<td>true</td>
							<td>Enable swiping</td>
						</tr>
						<tr>
							<td>touchMove</td>
							<td>boolean</td>
							<td>true</td>
							<td>Enable slide motion with touch</td>
						</tr>
						<tr>
							<td>touchThreshold</td>
							<td>int</td>
							<td>5</td>
							<td>Swipe distance threshold</td>
						</tr>
						<tr>
							<td>vertical</td>
							<td>boolean</td>
							<td>false</td>
							<td>Vertical slide mode</td>
						</tr>
					</tbody>
				</table>
				<h2>Methods</h2>
				<table class="methods">
					<thead>
						<tr>
							<th class="first">Method</th>
							<th>Arguments</th>
							<th class="last">Description</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>slickGoTo</td>
							<td>int : slide number</td>
							<td>Navigates to a slide by index</td>
						</tr>
						<tr>
							<td>slickNext</td>
							<td>none</td>
							<td>Navigates to the next slide</td>
						</tr>
						<tr>
							<td>slickPrev</td>
							<td>none</td>
							<td>Navigates to the previous slide</td>
						</tr>
						<tr>
							<td>slickPause</td>
							<td>none</td>
							<td>Pauses autoplay</td>
						</tr>
						<tr>
							<td>slickPlay</td>
							<td>none</td>
							<td>Starts autoplay</td>
						</tr>
						<tr>
							<td>slickAdd</td>
							<td>html or DOM object, index, addBefore</td>
							<td>Add a slide. If an index is provided, will add at that index, or before if addBefore is set. If no index is provided, add to the end or to the beginning if addBefore is set. Accepts HTML String || Object</td>
						</tr>
						<tr>
							<td>slickRemove</td>
							<td>index, removeBefore</td>
							<td>Remove slide by index. If removeBefore is set true, remove slide preceding index, or the first slide if no index is specified. If removeBefore is set to false, remove the slide following index, or the last slide if no index is set.</td>
						</tr>
						<tr>
							<td>slickFilter</td>
							<td>Selector or Function</td>
							<td>Filters slides using jQuery .filter()</td>
						</tr>
						<tr>
							<td>slickUnfilter</td>
							<td>index</td>
							<td>Removes applied filtering</td>
						</tr>
						<tr>
							<td>slickSetOption</td>
							<td>option : string, value : depends on option, refresh : boolean</td>
							<td>Sets an individual value live. Set refresh to true if it's a UI update.</td>
						</tr>
						<tr>
							<td>unslick</td>
							<td>none</td>
							<td>Deconstructs slick</td>
						</tr>
					</tbody>
				</table>
			</div>
		</section>
		<script>hljs.initHighlightingOnLoad();</script>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
</div>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 圖片放大鏡 圖片拖動 圖片拖拽 圖片疊加 圖片層疊 圖片翻轉 圖片旋轉 圖片延遲加載 圖片延遲 圖片加載 圖片淡出淡進 圖片淡出 圖片淡進 圖片全屏 頭像上傳 圖片上傳 二維碼 h5圖片動畫 h5圖標動畫 html5圖片動畫 html5圖標動畫 帶縮略圖的幻燈片 地圖 中國地圖 世界地圖 圖片放大縮小 圖片縮放 圖片大小 圖片放大 圖片縮小 圖片變大 圖片變小 滑動 滑塊 滑動門 觸屏滑動 滑動插件 滑塊插件 滑動選項卡 滑動切換 滾動切換 滾動條切換 圖片廣告 旋轉木馬 圖片旋轉木馬 文字旋轉木馬 旋轉木馬插件 圖片滑動 圖片滑塊 純圖片輪播 圖片輪播 圖片切換 圖片選項卡 圖標選項卡 圖片收縮展開 圖片收縮 圖片展開 圖片滾動 圖片滾動條 自動滾動圖片輪播 圖標導航 圖標菜單 選項卡切換 選項卡 切換 tab切換 頁面切換 選項卡插件 切換插件 滑動手風琴 背景切換 大圖切換 手風琴 水平手風琴 垂直手風琴 圖片手風琴 文字手風琴 手風琴插件 漸隱切換 延遲加載 無限加載 延遲 加載 淡出淡進 淡出 淡進 切換按鈕 表單 表單美化 表單插件 表單美化插件 圖表 圖片 圖片插件 頭像截圖 圖片延遲加載 圖片延遲 圖片加載 圖片淡出淡進 圖片淡出 圖片淡進 圖片滑動 圖片滑塊 圖片切換 圖片選項卡 圖標選項卡 圖片切換 切換圖片 按鈕控制
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

老夫子电子