我无法让我的 jquery 图像滑块滚动到下一组图像。当我单击下一个箭头时,它不断将我带回页面顶部。我也不确定下一行图像是否设置正确。对不起,但我是使用 jquery 的新手。
html
<div id="wrapper2">
<label style="color: #5C5C5C;display: block; font-weight: bold; font-size:16px; text-align: center;margin-bottom:0px;padding-bottom:20px;">Reaching our Goal is proud to partner with great organizations</label>
<div id="thumbs-wrapper2">
<div id="thumbs">
<a class="selected" href="#2"><img src="/assets/images/ROG_p.jpg" /></a>
<a href="#"><img src="/assets/images/gametime_p.jpg" /></a>
<a href="#"><img src="/assets/images/american_p.jpg" /></a>
<a href="#"><img src="/assets/images/bfs_p.jpg" /></a>
<a href="#"><img src="/assets/images/vballfestival_p.jpg" /></a>
<a href="#"><img src="/assets/images/yfbca_p.jpg" /></a>
<a href="#"><img src="/assets/images/sportsattack_p.jpg" /></a>
<a href="#"><img src="/assets/images/ROG_p.jpg" /></a>
<a href="#"><img src="/assets/images/gametime_p.jpg" /></a>
<a href="#"><img src="/assets/images/american_p.jpg" /></a>
<a href="#"><img src="/assets/images/bfs_p.jpg" /></a>
<a href="#"><img src="/assets/images/vballfestival_p.jpg" /></a>
<a href="#"><img src="/assets/images/yfbca_p.jpg" /></a>
<a href="#"><img src="/assets/images/sportsattack_p.jpg" /></a>
</div>
<a id="prev" href="#"></a>
<a id="next" href="#"></a>
</div>
</div>
脚本
$('#thumbs').carouFredSel({
responsive: true,
auto: true,
prev: '#prev',
next: '#next',
items: {
visible:
min: 2,
max: 4
},
width: 150,
height: '25%'
});
});
$('#thumbs a').click(function() {
$('#carousel').trigger('slideTo', '#'+this.href.split('#').pop());
$('#thumbs a').removeClass('selected');
$(this).addClass('selected');
return false;
});
css
#wrapper2 {
position: relative;
width: 100%;
top: 50px;
}
#carousel, #thumbs {
overflow: hidden;
height: 62px;
}
#carousel span, #carousel img,
#thumbs a, #thumbs img {
display: block;
float: left;
}
#carousel span, #carousel a,
#thumbs span, #thumbs a {
position: relative;
}
#carousel img,
#thumbs img {
border: medium none;
height: 58px;
left: 0;
position: relative;
top: 0;
width: 100px;
}
#carousel img.glare,
#thumbs img.glare {
width: 102%;
height: auto;
}
#thumbs-wrapper2 {
padding: 20px 40px;
position: relative;
width: 73%;
margin: -18px 0 0 162px;
height: 90px;
}
#thumbs a {
height: 58px;
margin: 0 10px;
overflow: hidden;
width: 100px;
border: 2px solid #899;
border-radius: 10px;
-webkit-transition: border-color .5s;
-moz-transition: border-color .5s;
-ms-transition: border-color .5s;
transition: border-color .5s;
}
#thumbs a:hover, #thumbs a.selected {
border-color: #566;
}
#prev, #next {
display: block;
height: 50px;
margin: -38px 0 0 -35px;
position: absolute;
top: 50%;
width: 50px;
}
#prev {
background-image: url(/assets/images/left.jpg);
background-position: 0 0;
left: 10px;
}
#next {
background-image: url(/assets/images/right.jpg);
background-position: -50px 0;
right: 33px;
}
#prev:hover {
background-position: 0 0;
}
#next:hover {
background-position: -50px 0;
}
#prev.disabled, #next.disabled {
display: none !important;
}