Cats and Code
A Feline-Friendly Space on the Interwebs

Slideshow

←   Return

Slideshow with 4 versions

slideshow

DEMO 1Simplest - assumes you are working with a full-size screen, so the arrows are on the sides.

DEMO 2Works with both large and smaller screens. When the screen size shrinks to 700 pixels, the arrow appear on the top instead of on the sides, so there's a little more in the css file.

DEMO 3 Includes thumbnails of all the images at the bottom. You can click on a thumbnail and the corresponding full image will appear.

DEMO 4 Images change automatically every 2000 ms, as a carousel. Click here for demo in a file I called 'images'. My index.php file gathers all the pictures into an array called 'slideshowarray', using the 'scandir' command. Each each picture gets saved in a variable called 'imagefile' and displayed on the screen, except.... they all get set to 'display: none'. They are there, but invisible! Haha - that's the magic trick!

Each image gets an 'onclick' attribute. When you click on it, javascript changes the 'display: none' to .... 'display: block'. And, it changes the 'display: block' for the previous image to .... 'display: none'.

( I separated out the 'header' and 'footer' code to hopefully make things more readable.)

screenshot of folders

You can view the main code for each version below.

SLIDESHOW 1 Code

Download

SLIDESHOW1/inc

SLIDESHOW 2 Code

Download

SLIDESHOW2/inc

SLIDESHOW 3 Code

Download

SLIDESHOW3/inc

SLIDESHOW 4 Code

Download

SLIDESHOW4/inc