我正在尝试使用我以前多次使用过的 jquery 滑块 - 但这次它不起作用,我不知道为什么。
这是 HTML 代码,基本上只是一个主滑块 div,里面有另一个 div 用于幻灯片,每个幻灯片 div 都有一个幻灯片类(对不起,我不能在没有“更多解释”的情况下发布这个):
<div id="slider">
<div id="slides">
<div class="slide">
<img src="images/portfolio/web1.jpg" alt=""/>
</div>
<div class="slide">
<img src="images/portfolio/web5.jpg" alt=""/>
</div>
</div>
<img src="images/arrow-L.png" alt="Left" id="slider-arrow-left"/>
<img src="images/arrow-R.png" alt="Right" id="slider-arrow-right"/>
</div>
而 CSS,只是设置高度和宽度:
#slider{height: 200px; position: relative; z-index: 1;}
#slider #slides {height: 200px; width: 883px; overflow: hidden; position: absolute; top: 0px; left: 0px;}
#slider #slides .slide{height: 200px; width: 883px;}
#slider img#slider-arrow-left {position: absolute; left: -30px; top: 80px; cursor: pointer; z-index: 999;}
#slider img#slider-arrow-right{position: absolute; right: 0px; top: 80px; cursor: pointer; z-index: 999;}
和jQuery:
$(document).ready(function(){
$('#slides').cycle({
fx: 'scrollHorz',
speed: 'slow',
timeout: 10000,
pause: 1,
prev: $('#slider-arrow-left'),
next: $('#slider-arrow-right'),
cssBefore:{
top: 0,
opacity: 1,
display: 'block'
},
animOut: {
top: 360
},
before: function(curr, next, opts){
var $curr = $(curr);
var $next = $(next);
},
pause: 1,
pager: '#slider-controls',
pagerAnchorBuilder: function (idx, slide) {
return '#slider-controls li:eq(' + idx + ') a';
}
});
});