有两种应用方式:

1、轮播图片作为<img>标签使用

HTML代码:

<html>
<head>
<meta charset="utf-8">
<script src="jquery-1.11.1.min.js"></script>
<script src="unslider.min.js"></script>
</head> <body>
<!-- example_begin -->
<h2>示例</h2> <div class="banner" id="b04">
<!-- 作为img标签使用 -->
<ul>
<li><img src="data:images/01.jpg" alt="" width="640" height="480"></li>
<li><img src="data:images/02.jpg" alt="" width="640" height="480"></li>
<li><img src="data:images/03.jpg" alt="" width="640" height="480"></li>
<li><img src="data:images/04.jpg" alt="" width="640" height="480"></li>
<li><img src="data:images/05.jpg" alt="" width="640" height="480"></li>
</ul>
<a href="javascript:void(0);" class="unslider-arrow04 prev"><img class="arrow" id="al" src="data:images/arrowl.png" alt="prev" width="20" height="35"></a>
<a href="javascript:void(0);" class="unslider-arrow04 next"><img class="arrow" id="ar" src="data:images/arrowr.png" alt="next" width="20" height="37"></a>
</div>
<!-- example_end -->
</body>
</html>

CSS代码:

html,body {
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
}
ul,ol {
padding:;
} .banner {
position: relative;
overflow: auto;
text-align: center;
} .banner li {
list-style: none;
} .banner ul li {
float: left;
} #b04 {
width: 640px;
} #b04 .dots {
position: absolute;
left:;
right:;
bottom: 20px;
} #b04 .dots li {
display: inline-block;
width: 10px;
height: 10px;
margin: 0 4px;
text-indent: -999em;
border: 2px solid #fff;
border-radius: 6px;
cursor: pointer;
opacity: .4;
-webkit-transition: background .5s, opacity .5s;
-moz-transition: background .5s, opacity .5s;
transition: background .5s, opacity .5s;
} #b04 .dots li.active {
background: #fff;
opacity:;
} #b04 .arrow {
position: absolute;
top: 200px;
} #b04 #al {
left: 15px;
} #b04 #ar {
right: 15px;
}

JS代码:

$(document).ready(function (e) {
var unslider04 = $('#b04').unslider({
dots: true
}),
data04 = unslider04.data('unslider'); $('.unslider-arrow04').click(function () {
var fn = this.className.split(' ')[1];
data04[fn]();
});
});

效果图:

2、轮播图片作为<li>标签背景图片使用

HMTL代码:

<html>
<head>
<meta charset="utf-8">
<script src="jquery-1.11.1.min.js"></script>
<script src="unslider.min.js"></script>
</head> <body>
<!-- example_begin -->
<h2>示例</h2> <div class="banner" id="b04">
<!-- 作为背景图片使用 -->
<ul>
<li id="index_pic1" class="index_pic1"></li>
<li id="index_pic2" class="index_pic2"></li>
<li id="index_pic3" class="index_pic3"></li>
<li id="index_pic4" class="index_pic4"></li>
<li id="index_pic5" class="index_pic5"></li>
</ul>
<a href="javascript:void(0);" class="unslider-arrow04 prev"><img class="arrow" id="al" src="data:images/arrowl.png" alt="prev" width="20" height="35"></a>
<a href="javascript:void(0);" class="unslider-arrow04 next"><img class="arrow" id="ar" src="data:images/arrowr.png" alt="next" width="20" height="37"></a>
</div>
<!-- example_end -->
</body>
</html>

CSS代码:在上面CSS的基础上添加以下代码

.index_pic1{
width: 640px;
height: 480px;
margin: 0 auto;
overflow: hidden;
background: url(images/01.jpg) no-repeat;
} .index_pic2{
width: 640px;
height: 480px;
margin: 0 auto;
overflow: hidden;
background: url(images/02.jpg) no-repeat;
} .index_pic3{
width: 640px;
height: 480px;
margin: 0 auto;
overflow: hidden;
background: url(images/03.jpg) no-repeat;
} .index_pic4{
width: 640px;
height: 480px;
margin: 0 auto;
overflow: hidden;
background: url(images/04.jpg) no-repeat;
} .index_pic5{
width: 640px;
height: 480px;
margin: 0 auto;
overflow: hidden;
background: url(images/05.jpg) no-repeat;
}

JS代码:与上面的JS代码一致

效果图:

总结:

轮播图片作为img标签时,在显示区域大小固定的情况下适用;在轮播图片需要跟随可视窗口大小自适应的情况下,作为li标签背景更妥当

最新文章

  1. Tips collection of iOS development
  2. 在ios android设备上使用 Protobuf (使用dll方式)
  3. java中常用的工具类(三)
  4. rosetta common sh: mpiCC command not found解决方法
  5. python 编码与解码 decode解码 encode 编码
  6. MVC之Razor语法
  7. 非对称认证方式 可以用在 asp.net webapi 的安全机制里面
  8. ORA-22275: invalid LOB locator specified
  9. highcharts时间图
  10. mudOS配置
  11. ASP.NET MVC5 学习笔记-4 OWIN和Katana
  12. 图解函数重载以及arguments
  13. mui开发app之自定义事件以更新其他页内容
  14. selenium+python+eclipse 实现 “问卷星”网站,登录与检查登录示例!
  15. 测试中Android与IOS分别关注的点
  16. Codeforces Round #412 C. Success Rate
  17. Hunter’s Apprentice 【判断多边形边界曲线顺逆时针】
  18. 无法将类型“System.Collections.Generic.List&lt;anonymous type:string ClassID,string ClsssName&gt;”隐式转换为“System.Collections.Generic.List&lt;Ecology.Model.EnergyFlowGraph&gt;”
  19. Redis went away
  20. 【ARM】AD转换器

热门文章

  1. java反射机制(转)
  2. HDU - 5534 Partial Tree(每种都装的完全背包)
  3. 51Nod - 1092 回文字符串(添加删除字符LCS变形)
  4. EntityFramework 中的链接研究初探
  5. C++经典面试算法题
  6. php 连接 memcached 并调用
  7. IT兄弟连 JavaWeb教程 jQuery对AJAX的支持
  8. appium运行遇到的坑01
  9. SpringBoot2.0 基础案例(13):基于Cache注解模式,管理Redis缓存
  10. java五行代码导出Excel