Javascript Image Slider > Posts >

 

Multiple sliders within one page

Martin
9 months ago
Viewed: 4646
16
Useful
Hello, i'm trying multiple sliders on the same page, and it works by the following approach.
HTML:
<div id="sliderFrame1"> <div id="slider1"> <img src="images/image-slider-1.jpg" alt="" /> <img src="images/image-slider-2.jpg" alt="" /> ... ... </div> </div> ... ... <div id="sliderFrame2"> <div id="slider2"> <img src="images/image-slider-3.jpg" alt="" /> <img src="images/image-slider-4.jpg" alt="" /> ... ... </div> </div>
Javascript:
This is part of my js-image-slider.js code (NOTE: Link this script only once. One copy only.):

var sliderOptions1= { sliderId: "slider1", effect: "13,17,13,13,5", ... ... }; var sliderOptions2= { sliderId: "slider2", effect: "13", ... ... }; var imageSlider1=new mcImgSlider(sliderOptions1); var imageSlider2=new mcImgSlider(sliderOptions2); ..... (other codes remain untouched)....
CSS:
And then I included two copies of stylesheets: js-image-slider1,css, and js-image-slider2.css:
For js-image-slider1.js, I change all selectors to be:
#sliderFrame1 {position:relative;width:500px;margin: 0;} #slider1 { ... } #slider1 img {...}

For js-image-slider2.js, I change all selectors to be:
#sliderFrame2 {position:relative;width:340px;margin: 0 auto;} #slider2 { ... } #slider2 img {...}
...



6 months ago
Mitch   Edit
1

I think you left out one step though. Putting the link to the second CSS file in the header.

I do have one issue. When the page loads, its not showing the loader and instead shows all 4 of the images briefly. Any ideas what I did wrong?

Thanks again
Mitch



6 months ago
milo   Edit
2

That means your CSS has something wrong. It should not happen with the existing CSS code below:
#slider1 {
background:#fff url(loading.gif) no-repeat 50% 50%;
}
#slider1 img {
... ...
display:none;
}


one month ago
shelim   Edit
0

Visit my site manandtools.co.uk
I got it working. Easy when you know how. I will put a link to all files used.


New Answer