simple Zoomable Images Gallery Called jPhotoGrid with jQuery
This plugin takes a simple list of images and captions and turns it into a grid of photos that can be explored and zoomed.
Overview
Nearly all of the styling for this plugin is done in css. The trick is to layout the grid by floating the list items. The first thing the plugin will then do, is convert these all to absolutely positioned. This is what allows the plugin to zoom in on an individual image and then return it to its place. Like my interactive map plugin, this depends on the browsers ability to scale images. In my stylesheet, the images are set to width:100% and I simply animate the size of the container.
The Markup
The html for this plugin is simply an unordered list of images and captions. Here is the format:
<ul> <li> <img src="/hifi/site/edit/blog/source.jpg" alt="" /> <p>Caption Here</p> </li> ... </ul>
The CSS
The CSS is also fairly straight-forward. The key things to notice are the .active and .selected classes. When you hover over a list item, it is given the class 'active'. Once you have clicked the list item, it is given the 'selected' class.
#pg { position: relative; height: 585px; background: #000; } #pg li { position: relative; list-style: none; width: 175px; height: 117px; overflow: hidden; float: left; z-index: 2; opacity: .3; } #pg li.active { opacity: 1; } #pg li.selected { opacity: 1; z-index: 99; -moz-box-shadow: 0px 0px 10px #fff; -webkit-box-shadow: 0px 0px 10px #fff; } #pg li img { display: block; width: 100%; } #pg li p { color: white; margin: 10px 0; font-size: 12px; }
The Javascript
The javascript is easy enough to set up. It needs to know the sizing of the thumbnails as well as the sizing and positioning of the zoomed image. This is how the plugin is able to zoom and restore each of the images. Note that you can also change the active and selected classes by setting them using the 'activeClass' and 'selectedClass' options.
$('#pg').jphotogrid({ baseCSS: { width: '175px', height: '117px', padding: '0px' }, selectedCSS: { top: '50px', left: '100px', width: '500px', height: '360px', padding: '10px' } });
You might also like
Recommend Items
Tags
accordion accordion menu animation navigation animation navigation menu carousel checkbox inputs css3 css3 menu css3 navigation date picker dialog drag drop drop down menu drop down navigation menu elastic navigation form form validation gallery glide navigation horizontal navigation menu hover effect image gallery image hover image lightbox image scroller image slideshow multi-level navigation menus rating select dependent select list slide image slider menu stylish form table tabs text effect text scroller tooltips tree menu vertical navigation menu