Image slider

From Organic Design wiki
Revision as of 21:54, 31 March 2015 by Nad (talk | contribs)

Here's a simple image slider written 100% in JavaScript and jQuery. In converts any div elements of class "image-slider" containing img elements into a slider like the one below. You can use your own CSS rules to give the next/prev links a nicer style and make a frame around the image. The images should all be the same size for it to work properly. The code is in our Subversion repository here.

There are two variables at the start of the code, delay and thumbWidth, these determine the time in seconds before the next image change, and the width in pixels of the thumbnail images below the sliding image. Each image slider div element can be configured to have a row of clickable thumbnail images below the sliding image by adding "thumbs" to the class attribute as in the example code following.

In the wiki you can use image links as follows:

<xml>
   Butterfly3.jpg
   YellowButterfly.jpg
   MonarchOnPinkTree3.jpg
   Butterfly1.jpg
</xml>


Here's an example of a pure HTML page which has the links to the scripts and images included:

<xml><!DOCTYPE html>

Image Slider

</xml>


Here's a working example:

Butterfly3.jpg Ethilla Longwing 1.jpg Butterfly1.jpg Blue butterfly on chia.jpg 2015 red butterfly 2.jpg


If you want to use the same CSS as this working example, the rules are as follows:

{{{1}}}