效果图:
HTML代码:
CSS样式:
@charset "utf-8";
body {
font-size: 12px;
font-family: "宋体", Arial, sans-serif;
color: #343434;
background: #000;
}
html,
body,
div,
span,
p,
h1,
h2,
h3,
h4,
h5,
h6,
em,
img,
strong,
sub,
sup,
tt,
dd,
dl,
dt,
form,
label,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
ul,
li,
p,
a {
margin: 0;
padding: 0;
}
.cbody988 {
margin: 0 auto;
width: 988px;
position: relative;
}
.cbody937 {
margin: 0 auto;
width: 937px;
position: relative;
padding-left: 7px;
}
input,
select,
textarea,
img {
vertical-align: middle;
}
img {
border: 0;
}
ul,
li {
list-style-type: none;
}
a:link,
a:visited {
text-decoration: none;
color: #343434;
}
a:hover {
text-decoration: underline;
color: #0F6BD0;
}
.overhide {
overflow: hidden;
text-indent: -100em;
}
/*位置属性*/
.marTop10 {
margin-top: 10px;
}
.left {
float: left;
}
.right {
float: right;
}
.clear {
clear: both;
}
.clearfix:after {
clear: both;
content: '';
display: block;
font-size: 0;
line-height: 0;
visibility: hidden;
width: 0;
height: 0;
}
.clearfix {
display: +inline-block;
}
/*header*/
#header {
border-bottom: 1px solid #383838;
height: 46px;
position: relative;
line-height: 46px;
color: #FFFFFF;
}
#header span {
position: absolute;
right: 10px;
top: 0px;
color: #9A9A9A;
font-size: 12px;
font-weight: normal;
}
#header span a {
color: #9A9A9A;
margin: 0 3px;
}
/*wrapper*/
#wrapper {
width: 960px;
margin: 0 auto;
}
#picSlideWrap {
background: #F5F8FD;
border: 1px solid #A9BFD6;
padding-bottom: 30px;
}
.imgnav {
width: 788px;
margin: 10px auto;
}
.imgnav {
position: relative;
margin: 0 auto;
width: 788px;
}
#img {
z-index: 10;
width: 788px;
position: relative;
text-align: center;
}
#img img {
height: 570px;
display: none;
border: 4px solid #000;
}
#prev {
position: absolute;
left: 0px;
top: 0px;
z-index: 10;
cursor: pointer;
width: 394px;
height: 578px;
background: url(../images/ico/blank.gif);
}
#prev a {
position: absolute;
left: 20px;
top: 224px;
display: block;
background: url(../images/ico/imgSlideLeft.png) no-repeat;
width: 104px;
height: 104px;
display: none;
}
#next {
position: absolute;
right: 0px;
top: 0px;
z-index: 10;
cursor: pointer;
width: 394px;
height: 578px;
background: url(../images/ico/blank.gif);
}
#next a {
position: absolute;
right: 20px;
top: 224px;
display: block;
background: url(../images/ico/imgSlideRight.png) no-repeat;
width: 104px;
height: 104px;
display: none;
}
#btns {
background: #EAEBF0;
position: relative;
height: 122px;
border: 1px solid #D6D9DC;
margin-top: 12px;
}
#btns ul {
position: relative;
width: 10000px;
height: 122px;
}
#btns ul li {
float: left;
padding: 8px 3px 3px 3px;
width: 116px;
height: 86px;
cursor: pointer;
text-align: center;
margin-right: 20px;
position: relative;
}
#btns ul li img {
width: 116px;
height: 86px;
display: block;
}
#btns ul li tt {
background: #000;
color: #FFF;
position: absolute;
right: 4px;
bottom: 4px;
z-index: 20;
font-family: "宋体";
font-size: 12px;
line-height: 16px;
padding: 0 5px;
}
#btns li.hov {
background: url(../images/ico/imgHoverBg.gif) no-repeat;
}
.ctrl div {
clear: both;
}
#cSlideUl {
width: 690px;
height: 116px;
overflow: hidden;
position: relative;
top: 10px;
margin: 0 auto;
}
.picSildeLeft {
cursor: pointer;
position: absolute;
top: 32px;
left: 10px;
z-index: 9;
}
.picSildeRight {
cursor: pointer;
position: absolute;
top: 32px;
right: 10px;
z-index: 9;
}
jQuery代码:
$(function() {
var index = 0;
var length = $("#img img").length;
var i = 1;
//关键函数:通过控制i ,来显示图片
function showImg(i) {
$("#img img")
.eq(i).stop(true, true).fadeIn(800)
.siblings("img").hide();
$("#btns li")
.eq(i).addClass("hov")
.siblings().removeClass("hov");
}
function slideNext() {
if(index >= 0 && index < length - 1) {
++index;
showImg(index);
} else {
if(confirm("已经是最后一张,点击确定重新浏览!")) {
showImg(0);
index = 0;
aniPx = (length - 5) * 142 + 'px'; //所有图片数 - 可见图片数 * 每张的距离 = 最后一张滚动到第一张的距离
$("#cSlideUl ul").animate({
"left": "+=" + aniPx
}, 200);
i = 1;
}
return false;
}
if(i < 0 || i > length - 5) {
return false;
}
$("#cSlideUl ul").animate({
"left": "-=142px"
}, 200)
i++;
}
function slideprev() {
if(index >= 1) {
--index;
showImg(index);
}
if(i < 2 || i > length + 5) {
return false;
}
$("#cSlideUl ul").animate({
"left": "+=142px"
}, 200)
i--;
}
$("#img img").eq(0).show();
$("#btns li").eq(0).addClass("hov");
$("#btns tt").each(function(e) {
var str = (e + 1) + "/" + length;
$(this).html(str)
})
$(".picSildeRight,#next").click(function() {
slideNext();
})
$(".picSildeLeft,#prev").click(function() {
slideprev();
})
$("#btns li").click(function() {
index = $("#btns li").index(this);
showImg(index);
});
$("#next,#prev").hover(function() {
$(this).children("a").fadeIn();
}, function() {
$(this).children("a").fadeOut();
})
})
如果感觉还不错,麻烦给个小心心。