jquery制作响应式图片插件


jquery制作响应式图片插件
jquery制作响应式图片插件以及响应式图片等js/jquery网页特效代码下载。

1. 引入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/jquery.js"></script>
<script type="text/javascript" src="slick/slick.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>

3. HTML代码

		<div class="header">
			<div class="header-content">
				<h1 class="title">slick</h1>
				<p class="subheading">the last carousel you'll ever need</p>
				<ul class="nav">
					<li><a href="#demos">demos</a></li>
					<li><a href="#getting-started">usage</a></li>
					<li><a href="#settings">settings</a></li>
					<li><a href="#go-get-it">get it now</a></li>
				</ul>
			</div>
		</div>
		<div class="fixed-header">
			<div class="header-content">
				<h1 class="title">slick</h1>
				<p class="subheading">the last carousel you'll ever need</p>
				<ul class="nav">
					<li><a href="#demos">demos</a></li>
					<li><a href="#getting-started">usage</a></li>
					<li><a href="#settings">settings</a></li>
					<li><a href="#go-get-it">get it now</a></li>
				</ul>
			</div>
		</div>
		<section id="features" class="blue">
			<div class="content">
				<h2>Features</h2>
				<ul class="features">
					<li>Fully responsive. Scales with its container.</li>
					<li>Separate settings per breakpoint</li>
					<li>Uses CSS3 when available. Fully functional when not.</li>
					<li>Swipe enabled. Or disabled, if you prefer.</li>
					<li>Desktop mouse dragging</li>
					<li>Infinite looping.</li>
					<li>Fully accessible with arrow key navigation</li>
					<li>Add, remove, filter & unfilter slides</li>
					<li>Autoplay, dots, arrows, callbacks, etc...</li>
				</ul>
				<hr id="demos"/>
				<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.jpg"/></div></div>
					<div><div class="image"><img src="img/fonz2.jpg"/></div></div>
					<div><div class="image"><img src="img/fonz3.jpg"/></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);
  if (slideIndex !== 0) {
  	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>slickCurrentSlide</td>
							<td>none</td>
							<td>Returns the current slide index</td>
						</tr>
						<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>
		<script type="text/javascript">
        var disqus_shortname = 'slickcarousel';
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>

相关推荐

发表评论

相关文章