I’m trying to use a jquery slider that I’ve used many times before – but this time it isn’t working and I can’t figure out why.
Here is the HTML Code, basically just a main slider div with another div inside for the slides and each slide div has a class of slide (sorry to ramble, I can’t post this without ‘more explanation’):
<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>
And the CSS, just setting heights and widths:
#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;}
And the 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';
}
});
});
I have tried your example using jQuery cycle plugin. and it seems fine,
Here :
jsFiddle
you may tweak it accordingly.