Cats and Code
>^..^<    A Feline-Friendly Space on the Interwebs    >^..^<
A Feline-Friendly Space on the Interwebs

>^..^<   

Slideshow

←   Return

Slideshow with 4 versions

slideshow

1 - Simplest - assumes you are working with a full-size screen, so the arrows are on the sides. Click here for demo

2 - Works 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. Click here for demo

3 - Includes thumbnails of all the images at the bottom. You can click on a thumbnail and the corresponding full image will appear.Click here for demo

4 - Images change automatically every 2000 ms, as a carousel. Click here for demo

Here's how it works:

There are 5 photos (of cats, of course) 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.)

You can view the main code for each version below.

SLIDESHOW 1 Code

Download

SLIDESHOW1/images
SLIDESHOW1/inc

SLIDESHOW 2 Code

Download

SLIDESHOW2/images
SLIDESHOW2/inc

SLIDESHOW 3 Code

Download

SLIDESHOW3/images
SLIDESHOW3/inc

SLIDESHOW 4 Code

Download

SLIDESHOW4/images
SLIDESHOW4/inc