Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library
 
CSS Library
Submit an original CSS code
CSS Layouts
Web Graphics
Online Tools:

Advertise Here

CSS Library: Image CSS: Here

CSS Image Gallery

Author: Dynamic Drive

This is a purely CSS based image gallery that displays larger versions of thumbnail images dynamically when the mouse hovers over them. A rich HTML caption can be added to the enlarged image, and every aspect of the Image Gallery exists as plain HTML on the page. The idea is to use CSS's ":hover" pseudo class to cause an element to react onMouseover. When that happens, an absolutely positioned container holding the enlarged image, anchored on the page by another container with position set to relative, is shown. Furthermore, it's possible to modify the behavior so the enlarged images are only shown onClick, though IE6 currently doesn't support this behavior well. The gallery works in IE6+, Firefox, Opera 8+.

Demo:

Note: Here the enlarged images are set to "overlay" any content that it may come in contact with. You can easily disable overlaying just by giving the gallery container (.gallerycontainer) a height set to that of the largest image's.

The CSS:

The HTML:

Code Info

Rate this code:

Date Posted: 05/07/2006

Revision History: None

Usage Terms: Click here

Your Comments (406)

Got a question or need help customizing this CSS code? Post it in the CSS Forums. If you have a comment or suggestion instead, post it in the comments section below.

Comment Pages 11 of 41 pages « First  <  9 10 11 12 13 >  Last »

I forgot to mention I changed this piece of code:

.thumbnail:hover span{ /*CSS for enlarged image*/
visibility: visible;
top: center;
left:250px; /*position where enlarged image should offset horizontally */
z-index: 50;
}
it was originally "0" but I want the enlarged img to follow along when the visitor scrolls down on the page
Posted by Kurt aka Mutley on 12/28, 07:40 PM
Great tutorial!

I'm countering a major problem tho...
I need to use this in an iframe, and when I hover a thumb the big picture is not fully shown.

This is because the big picture does not go outside the iframe at all.

Please help me with this problem, I would be forever thankful, either mail me or reply to this :)

//Fredric
Posted by Fredric T on 12/30, 06:47 AM
Its really nice and its really help full . My question is if i want to make the large picture to be stay there. How i am gonna do that. For example when u click on the picture small picture and the large should stay there even if u move the mouse
Posted by Designer on 01/02, 12:41 AM
The script works really well - thanks!
But, I have a long list of thumbnails which allow the user to scroll below the fixed main image display. Is there any way to make the main image display adjacent to the relevant thumbnail or to maintain it's position relative to the browser top rather than the page top?
Thanks
Posted by Michelle on 01/08, 05:14 PM
Really nice code... I put it into a notepad document, added my own pics and captions, and saved it as an html file and it worked perfectly. However, when I put the code into myspace, it spaces the thumbnails out and makes room below each one for the enlarged image to appear. Then it doesn't even show the large image when the mouse is hovered over the thumbnail. I'd appreciate any help on this matter. If anybody would like to, they can email about this at Brandonmc4@verizon.net.
Posted by Brandonmc4 on 01/10, 07:08 PM
Hello there,

I'm using WordPress and can't seem to fathom how to use the CSS in the stylesheet that has to be used for the theme. Can someone help me? MSN is thesoulgirl at hotmail.com

Karen x
Posted by Soulgirl on 01/11, 03:08 PM
This is absolutely awesome. I've used the technique and modified it alil bit for my needs (a little fanciful, but it works wonders). Right here.

Great work! Keep it up!
Posted by narrowband on 01/17, 03:48 AM
I love this gallery! It's just lovely. I redesigned my client's gallery with this one instead! It's amazing how many users appreciate viewing the larger image on a hover instead of a link/new page. Thank you!
Posted by Jenn on 01/17, 04:58 PM
In Safari and FireFox/Mac (and perhaps others), there is a wider gap on the right hand side of the large image (the yellow area between the dashed outline and the solid bloue border of the image). Is there any way to remove the extra gap width on the right side?
Posted by Peter N Lewis on 01/18, 12:40 AM
How would you modify this so that the first image appears as default?
For example, currently when you open up the page, the thumbnails are shown, but no main image until you hover over a thumbnail. It would be good if the first image could be always set to visible even while not hovering.

It would also need to be compatible in IE6
Posted by Simon on 01/23, 11:37 PM

Comment Pages 11 of 41 pages « First  <  9 10 11 12 13 >  Last »

Commenting is not available in this weblog entry.
Copyright 2006-2011 Dynamic Drive Read our Usage Terms before using any of the CSS codes.