Using CSS3, we can create beautiful fast loading thumbnail gallery which shows the bigger image on hovering.
In this example displayed below, we chose to display thumbnail images horizontally and provided transition for bigger images. Kindly hover on the thumbnail to view the gallery.
The steps followed to create the above gallery are given below:
1. Firstly we assign a main placeholder for the gallery. The style for which was
given as:
|
#thumbnail_gal_main
#thumbnail_gallery
|
NOTE: The above height and width parameters are arbitrary and would depend on the size of your gallery.
2. In the next step we assign the div for our thumbnail images, the style for which
was given as:
|
#thumbnail_gallery ul
/*Div for single thumbnail image*/
#thumbnail_gallery ul li /*Div for padding of thumbnail image*/
#thumbnail_gallery ul li a { }
/*Style for the thumbnail image */ |
3. In the third step we assign the placeholder and style for our big image, as given
below
|
#thumbnail_gallery ul li a b
{ position:absolute; left:-9999px; display:block; width:548px; height:365px; background-color:#000000; } |
In the above style, for the original position for the big image, the values are
given in negative so that it does not show before hovering takes place. The style
for the big image assigned was:
|
#thumbnail_gallery ul li a b img { width:auto; height:auto; border:1px solid #fff; } |
The style for the big image that would show on hovering above the thumbnail is shown
below:
|
#thumbnail_gallery ul li a:hover b img
{ width:auto; height:auto; border:1px solid #000; margin-left:6px; } |
|
#thumbnail_gallery ul li a:hover, #thumbnail_gallery ul li a:active, #thumbnail_gallery ul li a:focus {white-space:normal; border-color:#000; outline:0;} The style for the placeholder of big image on hovering the thumbnail is shown below:
#thumbnail_gallery ul li a:hover b
|
The HTML code for the above code is shown as:
|
<div id="thumbnail_gal_main"> <div id="thumbnail_gallery"> <img src="images/thumbnail_cover.jpg" alt="" align="left" style="margin:9px 0 0 8px"/> <ul> <li><a href="#"><img src="images/thumbnail_pic1.jpg" /><b><img src="images/thumbnail_pic1.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic2.jpg" /><b><img src="images/thumbnail_pic2.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic3.jpg" /><b><img src="images/thumbnail_pic3.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic4.jpg" /><b><img src="images/thumbnail_pic4.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic5.jpg" /><b><img src="images/thumbnail_pic5.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic6.jpg" /><b><img src="images/thumbnail_pic6.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic7.jpg" /><b><img src="images/thumbnail_pic7.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic8.jpg" /><b><img src="images/thumbnail_pic8.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic9.jpg" /><b><img src="images/thumbnail_pic9.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic10.jpg" /><b><img src="images/thumbnail_pic10.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic11.jpg" /><b><img src="images/thumbnail_pic11.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic12.jpg" /><b><img src="images/thumbnail_pic12.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic13.jpg" /><b><img src="images/thumbnail_pic13.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic14.jpg" /><b><img src="images/thumbnail_pic14.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic15.jpg" /><b><img src="images/thumbnail_pic15.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic3.jpg" /><b><img src="images/thumbnail_pic3.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic4.jpg" /><b><img src="images/thumbnail_pic4.jpg" /></b></a></li> <li><a href="#"><img src="images/thumbnail_pic5.jpg" /><b><img src="images/thumbnail_pic5.jpg" /></b></a></li> </ul> </div> </div> |
You can also try out placing the thumbnails on different positions,simply by making
few changes in the code, an example of which is shown below:
Tags: Fast loading CSS3 photo gallery, attractive CSS3 photo gallery, CSS3 photo gallery to display bigger images on thumbnail rollover.