Create a awesome images gallery using css3 and jquery

Today we will be creating a very simple but great looking css3 image gallery using jquery and css3. The image gallery will be tilted to the side and on hover will move. Whenever you click on the image a lightbox will pop out. So lets begin.

Folder Structure

In the folder of your for your image gallery you should have 3 folders and 2 files.

  • Css – Contains the jquery css
  • Images – Contains images
  • Js – Contains the javascript
  • index.html
  • style

file structure

The HTML Structure

For the image gallery I simply wrapped the gallery in a div and added the images. Every 4 image has two different classed assigned to them. For example the first 4 images has a class name of thumb-small and for the other 4 images they have a class name of thumb-bottom.

The Css

For the Css you might wonder what -webkit, and -moz-transform is. Webkit is a Css3 tag that targets the safari web browser and moz-transform is a Css3 tag that targets the Mozilla Firefox web browser. In the css

  1. -webkit-transform: – Used to rotate the images
  2. -webkit-transition: – Used to zoom/ease in on the images

Inserting and activating jquery plugins

First things first when activating a jquery plugin is to simply make sure we call in the jquery script. Insert the code below into the head section of your document. The code below calls in jquery, then the two jquery plugins, and finally the plugin Css.

Now we want to add the script below to the body of our HTML document right before the end of the body tag.

For the code below I will try to explain it the best way I can so you can better understand it. I know not everyone is good with inserting Javascript plugins or changing functions.

The first function inside of the script tag targets the light box plugin. The light box plugin is when you click on an image and the image enlarges without being taken to the direct image location.

For this $(“.thumb-top,.thumb-bottom”).fadeTo(“slow”, 0.3); function it just tells jquery to fade to anything with the class of thumb-top or thumb-bottom. So whenever your mouse is not on the image it will be darken.

For this $(“.thumb-top,.thumb-bottom”).hover(function(){ function it just tells you on hover, or whenever you move over the image with your mouse that it will highlight the image.

For the $(‘#gallery a’).lightBox(); function it just asks you what id tag would you like for it to bring up whenever you click on something with the tag of a href. For example I have the images wrapped inside of the id gallery and every image has an a href assign to it so whenever you click on it jquery knows when to call for the second lightbox function.
pop out
Note: Rotation does not work in Internet explorer browsers do to lack of support of Css3.

After that you should now have your very own css3/jquery image gallery. I am no jquery expert but I try to help you guys understand it and a easy way instead of using words that you guys are not familiar with.


Credit goes to Csswizardry for the css3 image gallery.
Credit goes to Leandrovieira for the lightbox plugin.

Joe Granados the author

Joe Granados is the owner of WebDevTuts. He is also a web designer & developer who loves to design and develop websites. If you're looking for him you can find him via @webdevtuts
    • Marcell says:

      I’m not really sure but I’m guessing it can work with flash considering I have seen a bunch of sliders made in flash(jquery, mootool, etc)

  1. 2my says:

    I like the tutorial its fabulous..however mine seems to only work with mozilla only I was just wondering how i can make it compatible with IE as I saw in the tutorial u made it compatible with mozilla and safari only ….tx in adavance

Leave a Reply