Add Opacity/Transparency To An Image Using CSS

Opacity / Transparency are used by many design blogs to differentiate when a mouse over is done. So this post will teach you how to add opacity to image on your blog post and also for static images used in your template. This trick is very simple and easy to implement for both websites and blogs. So, irrelevant of your blogging platform this trick tutorial will help you to add transparency effect.

add opacity for images

For Blogger blogs:

Search for ]]></b:skin> and paste the the written code below ]]></b:skin>

a.opacity img {
-moz-opacity: 0.5;
opacity: 0.5;
filter:alpha(opacity=50);
}

a.opacity:hover img {
-moz-opacity: 1.0;
opacity: 1.0;
filter:alpha(opacity=100);
}

Once you are done with this step, add class=”opacity” between the image links using the Edit HTML tab for the post. For an example

opacity of image in blogger

Thats it you are done. Check out the live demo for Blogger

For WordPress Blogs:

Go to Appearance > Editor  and add the script you find below in it

a.opacity img {
-moz-opacity: 0.5;
opacity: 0.5;
filter:alpha(opacity=50);
}

a.opacity:hover img {
-moz-opacity: 1.0;
opacity: 1.0;
filter:alpha(opacity=100);
}

Then go to HTML mode in the post editor and follow the same step as I instructed for Blogger.

For websites:

Add the same CSS code and add class="opacity" as instructed for Blogger.

For static image in you template

For an instance, if you are adding opacity effect for static image in a template you can use this script. This script implies to both blogs and websites.

<img src="http://yourdomain.com/image.png" style="opacity:0.5;filter:alpha(opacity=50)"
onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
onmouseout="this.style.opacity=0.5;this.filters.alpha.opacity=50" />

Some times your image source starts with <img src at those case just add <a class="opacity"> and end it with </a> along with the CSS file.

Note: For WordPress blogs give around 4-5 minutes to see the effect.

July 4, 2010. This entry was posted in Blogger, CSS, Tutorials, WordPress and tagged . Bookmark the permalink.

We Recommend HostGator Hosting

Bloggermint strongly recommends Hostgator Hosting for all of your web hosting needs. Sign up today for WordPress Hosting at just $4.95/month.

Use coupon code "bloggermint" to get 25% discount on any hosting packages. Get an account with Hostgator now!

17 Responses so far!

  1. This Feature is Really Awesome! i have Added to my Blog ! Just took only 2 mins to Apply, Your Tutorial is Really Great and Easy to Follow!

    Cheers!!!
    .-= Karthikeyan´s last blog ..Google Buzz for Mobile =-.

  2. @Karthikeyan – Thanks for the appreciation.

  3. Pingback: Tweets that mention Add Opacity/Transparency To An Image Using CSS | Bloggermint -- Topsy.com

  4. Found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later

  5. really needed this trick. one of friends wanted to have transparency in an image.

  6. I am a wordpress user and I wanted to ask that where should I paste that code in the editor?

  7. @Vinayak – Paste it in custom.css file

  8. But where in it? I pasted it in the beginning but nothing happened? Where do I have to paste…. is there any code before which i have to paste it?

  9. So, I dont have to paste it in the custom.css?

  10. really good tips
    .-= ilmucts´s last blog ..Cara menempelkan flash animasi di blog =-.

  11. Hi!..These tutorials really useful to add more pleasurable images to website design..Great Job!
    .-= Philwebservices´s last blog ..Web 20 design marbella =-.

  12. Hello there Franklin, I am also interested in this. (See the most recent blog post on my site.) Your article is great to read; you’ve definitely provided me with lots of food for thought. – cars2scrap
    .-= Matthew´s last blog .. =-.

  13. I really like this tutorial. I am using it on my blog: http://experience.amelioraranch.com; however, when I try to the exact same thing for my amexperiencedirectory.com site, I get something “very funky” (that’s a technical term for floating script at the bottom of my images). I am using the same platform and the same theme… it is so strange. Do you have any ideas about what would cause this?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>