CSS: Image overlay caption


There are 2 image overlay caption related tutorials i made “Making image captions using jQuery” and“Making A Cool Thumbnail Effect With Zoom And Sliding Captions”. Feel free to check them out, they’re great :)
Both of them have some cool effect made with jQuery, but yesterday a reader (hi Goodluck) asked me how to have the captions shown by default without jQuery effects. So i realized i don’t have a tutorial explaining how to make a simple overlay image caption and here we are. Enjoy.

How it looks

CSS Caption


  2. <div class=‘wrapper’>  
  4.     <img src=‘wolf.jpg’ />  
  6.     <div class=‘description’>  
  8.         <p class=‘description_content’>The pack, the basic…</p>  
  10.     </div>  
  12. </div>  


  1. div.wrapper{  
  2.     float:left/* important */  
  3.     position:relative/* important(so we can absolutely position the description div */  
  4. }  
  5. div.description{  
  6.     position:absolute/* absolute position (so we can position it where we want)*/  
  7.     bottombottom:0px/* position will be on bottom */  
  8.     left:0px;  
  9.     width:100%;  
  10.     /* styling bellow */  
  11.     background-color:black;  
  12.     font-family‘tahoma’;  
  13.     font-size:15px;  
  14.     color:white;  
  15.     opacity:0.6; /* transparency */  
  16.     filter:alpha(opacity=60); /* IE transparency */  
  17. }  
  18. p.description_content{  
  19.     padding:10px;  
  20.     margin:0px;  
  21. }  

That’s it

And we have a nice transparent overlay image caption. If you don’t like that the text is also transparent then i can suggest you to use a transparent PNG image 1px wide and 1px tall as the background of the .description and remove the CSS opacity, or you can use javascript to make a transparent mask and on top of it show the caption text. If you like to see a tutorial on different ways to achieve that, let me know and i’ll see what i can do

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s