【示例源代码下载】:http://download.csdn.net/detail/yousuosi/6501701
Nivo Slider号称世界最棒的轻量级JQuery图片幻灯插件,按它的官网所说,“以漂亮和易于使用而闻名于世”!
憾人的效果可欣赏一下由Solagirl收集整理的实例展示:http://www.solagirl.net/mydemo/my-custom-nivo-slider/
五、Nivo Slider的样式
漂亮的幻灯片主要取决于样式设置,这首先要清楚它呈现时的HTML结构和内容,这个结构和内容是根据设置时的结构和内容在呈现时生成的,而设置时的结构和内容基本都设置为不显示了,简化的HTML结构和内容如下所示:
<!--Nivo Slider的封装-->
<div class="slider-wrapper">
<!--幻灯片-->
<div id="slider" class="nivoSlider">
<!--图片-->
<img style="display: inline; height: 397px; width: 998px;" src="images/nemo.jpg" class="nivo-main-image">
<!--标题-->
<div style="display: block;" class="nivo-caption">
<strong>This</strong> is an example of a <em>HTML</em> caption with <a href="#">a link</a>.
</div>
<!--方向切换按钮(上一页/下一页)-->
<div class="nivo-directionNav">
<a class="nivo-prevNav">Prev</a><a class="nivo-nextNav">Next</a>
</div>
</div>
<!--导航控制按钮(1,2,3... )-->
<div class="nivo-controlNav">
<a class="nivo-control" rel="0">1</a>
<a class="nivo-control" rel="1">2</a>
<a class="nivo-control" rel="2">3</a>
<a class="nivo-control active" rel="3">4</a>
</div>
</div>
这个结构和内容主要有四个组成部分:图片、标题、方向切换按钮(上一页/下一页)和导航控制按钮(1,2,3...),样式设置时,也主要是针对这几个部分进行设置的,官方提供的默认样式如下:
/*
* jQuery Nivo Slider v3.2
* http://nivo.dev7studios.com
*
* Copyright 2012, Dev7studios
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
/*Nivo Slider的封装*/
.slider-wrapper {
width:60%;
margin: 100px auto;
}
/*幻灯片的基本样式*/
/* The Nivo Slider styles */
.nivoSlider {
position:relative;
width:100%;
height:auto;
overflow: hidden;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
max-width: none;
}
/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
border:0;
padding:0;
margin:0;
z-index:6;
display:none;
background:white;
filter:alpha(opacity=0);
opacity:0;
}
/*切片和格子样式,一般不做修改。*/
/* The slices and boxes in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:5;
height:100%;
top:0;
}
.nivo-box {
display:block;
position:absolute;
z-index:5;
overflow:hidden;
}
.nivo-box img { display:block; }
/*图片样式*/
.nivo-main-image {
display: block !important;
position: relative !important;
width: 100% !important;
}
/*标题样式*/
/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#000;
color:#fff;
width:100%;
z-index:8;
padding: 5px 10px;
opacity: 0.8;
overflow: hidden;
display: none;
-moz-opacity: 0.8;
filter:alpha(opacity=8);
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.nivo-caption p {
padding:5px;
margin:0;
}
.nivo-caption a {
display:inline !important;
}
.nivo-html-caption { /*设置的图片标题,一般不显示*/
display:none;
}
/*方向切换按钮(上一页/下一页)*/
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
position:absolute;
top:45%;
z-index:9;
cursor:pointer;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
/*导航控制按钮(,2,3... )样式*/
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav {
text-align:center;
padding: 15px 0;
}
.nivo-controlNav a {
cursor:pointer;
}
.nivo-controlNav a.active {
font-weight:bold;
}
参考网址:
[1]Nivo Slider 简要使用文档.http://www.2cto.com/kf/201202/119195.html.
[2]基于JQuery Nivo Slider幻灯插件.http://www.111cn.net/wy/jquery/40801.htm.
[3]Nivo Slider官网教程:http://docs.dev7studios.com/jquery-plugins/nivo-slider