Unslider已经在所有最新的浏览器上测试过了,并且对那些老旧的浏览器也能很出色的降级处理。
如果需要,可以加入键盘方向键导航。试一试左右方向键吧!
并不是每个幻灯片都很规范,Unslider能够自动调整高度。
如今哪个网站还不支持响应式布局就已经非常OUT了。Unslider帮你轻松搞定!
To use Unslider, you’ll need to make sure both the Unslider and jQuery scripts are included. If you’ve already got jQuery (you can test by opening your JavaScript console and typing !!window.jQuery
— if it says true
, you have jQuery), you don’t need to add the first line.
<script src="//code.jquery.com/jquery-latest.min.js"></script> <script src="//unslider.com/unslider.js"></script>
Unslider doesn’t need any really awkward markup. In fact, all you need is a div
and an unordered list. An example of some Unslider-friendly HTML is on the right.
You can add as many slides as you want: the example on the right just has three for the sake of brevity, but Unslider won’t work properly with one slide (but then it’s just a box).
<div class="banner"> <ul> <li>This is a slide.</li> <li>This is another slide.</li> <li>This is a final slide.</li> </ul> </div>
You can change, add, and remove as much CSS per slide as you want, but there is a barebones style required by Unslider. It’s on the right (change the class name where .banner is the name of your slider).
.banner { position: relative; overflow: auto; } .banner li { list-style: none; } .banner ul li { float: left; }
We’ve been through so much together, and I’m pleased to say the finish line is near. Our journey is almost over, just one more thing left to do. The JavaScript is on the right (make sure to put it in a script
tag, and change .banner
to whatever your slider’s element is).
$(function() { $('.banner').unslider(); });