Did you like my previous CSS tutorial on how to create gradient text effects? I'm using the same trick to show you how to decorate your images and photo galleries without editing the source images. The trick is very simple. All you need is an extra <span> tag and apply a background image to create the overlaying effect. It is very easy and flexible — see my demos with over 20 styles, from a simple image icon to a rounded corner to a masked layer (both decorative and complex).
What Are The Benefits Of This CSS Trick?
- Saves Time — You don't have to manually create the decorative template in Photoshop and export the individual image.
- Keeps Original Source Images — So you don't have to worry about changing the design theme in the future.
- Very Flexible — You can have a completely different look and feel by just editing the CSS.
- It Works on Any Site — This CSS trick works on any type of site, with any image size.
- Cross-Browser CompatIble — It has passed the test on most browsers (Firefox, Safari, Opera, and even the "buggy IE6").
Basic Concept (see demo)
You need to insert an extra <span> tag within the <div> tag, with which we'll apply a background image to create the overlaying effect. If you don't like to have an empty span tag, you can append the span tag by Javascript (I'll show you how later in this tutorial). Here is how it works:
Then in the CSS, the key point you have to remember is: specify the div element to position:relative and the span element to position:absolute. You can position the span element anywhere you want by using the top and left property.
IE PNG Hack
To make the transparent PNG image work on IE6, I use this wonderful iepngfix.htc hack. Download a copy of iepngfix.htc and insert the following code in between the <head> tag:
<!--[if lt IE 7]>
<style type="text/css">
.photo span { behavior: url(iepngfix.htc); }
</style>
<![endif]-->
Look and Feel
To change the look and feel, simply edit the CSS specifications of the span element. Click the image below to see the demos I have. To show you how flexible it is, I've created 15 different styles (notice the HTML markup is same).
The jQuery Solution (see demo)
I know some of you (particularly the web accessibility fans) don't like to have an empty span tag in the markup. Well, I've solved this issue by using jQuery to append the span tag to the source code. Insert the following code in between the <head> tag:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//prepend span tag
$(".photo a").prepend("<span></span>");
});
</script>
#1. Simple Gallery (see demo)
Let's take the technique from the previous step and apply it to create a photo gallery.
#1b. Mini Icons (see demo)
This example shows you how to position different icons on top of each photo (note: an extra CSS class name is required in the span tag).
#2. Photo With Text (see demo)
This example shows you how to create a gallery with linking text (em tag).
#2b. Popup Text (see demo)
#3. Mini Paper Clip (see demo)
#4. Cork Board Gallery (see demo, IE6 version)
sIFR Version (Flash Text Replacement) (see sIFR demo)
This example uses sIFR to replace the em text with a handwritten font (notes: in this demo, the span tag is appended by jQuery)
#4b. Cork Board With Masking Tape (see demo, IE6 version)
#5. Art Gallery - Black Frame (see demo)
#5b. Art Gallery - Gold Frame (see demo)
#6. Grungy Watercolor (see demo)
sIFR Version (see sIFR demo)
#7. Glossy Style (see demo)
#8. Wood Panel Gallery (see demo)
Finally, this example demonstrates how you can apply the background image to all elements to create a wood panel gallery: ul, li, and em.
Final Remarks
As you can see, this CSS trick is very flexible. So, be creative! Feel free to incorporate the graphic images and CSS styles in this tutorial to create your own.
















#2. Photo With Text is so Good, Thank you.
Good – I should certainly pronounce, impressed with your site. I had no trouble navigating through all tabs and related info ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or anything, website theme . a tones way for your client to communicate. Nice task.
This tutorial is excellent.. Thank you
definitely, a BIG BIG deals.thx, for article
Nice tutorials they are very good. Thanks so much for sharing.
thank you .
better site
thanx for your tutorial
very nice…!
Can somebody please explain specifically how to apply this to NextGen gallery thumbnails? I would like to use a rounded thumbnail but i’m new to webdesign and i’m afraid of messing up my site (again). My NextGen Gallery can be seen here with the default boring square thumbnails: http://www.mattrice.comuf.com/wordpress/photos/photos-4-0/
Any help is appreciated!
Hi Matthew,
I’m having the same problem. Did they respond to you? If so, what was there response?
Peace,
Cecelia
I made a tutorial here, in order to apply this great tool to NextGen Gallery –> http://www.ajwan.net/wordpress/tutti-frutti/nextgen-custom-themes/
I hope it’ll help
Could you please tell me is there is a way to create something like the Featured Kittens section on http://PersianKittenEmpire.Com
Get all the thumbnails close together with effects.
Please let me know,
Thanks!
Great!! just what I needed. Thanks a lot! :)
Thank you Thank you!! This is organized very nicelytt
where is the code for :roudend corner:?
very nice…!
but i have a little problem , i use this method
http://www.webdesignerwall.com/demo/decorative-gallery/2_photo-with-text.html
and my bullet show in left picture, i want delete li bullet in this.
can any one help me?
Wow, great! I try this Cork Board Gallery!
where is the code for :roudend corner:?
I am curious to find out what blog system you’re utilizing? I’m experiencing some small security issues with my latest website and I would like to find something more secure. Do you have any recommendations?
I stumbled on this while googling for some lyrics, I’ll be sure to come back. thanks for sharing.
Can you please explain specifically how to apply this to NextGen gallery thumbnails in WordPress? I would like to use the gold frame thumbnail.
You can see my plain thumbnails here http://stlcatholic1.larryjacob.com/priests-deacons/
Thank you so much!!!
I’m so glad, found this tutorial. Thank you very much..