基于jQuery实现多种样式幻灯片切换特效



41 162 55



特效描述:基于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

加群请备注:从官网了解到