Web Tip: Image Rollovers with CSS Opacity (screencast)

08/04/2011 in tutorials,web tips

Vegan Donuts Vegan Donuts // Greenhouse Cafe, West Portal
(+ Click photo to enlarge)

I was looking at Alt’s speaker page last night and I noticed that the photos lightened when my mouse rolled over them. I assumed that the effect was accomplished with old school rollover techniques (switching multiple images or css sprites). However, when I checked with Firebug, I saw that they were using the opacity property! This technique is more common now that modern browsers can handle image opacity.

Vegan Donuts Vegan Donuts
(+ Click photo to enlarge)

The CSS opacity property can alter any element on your page (ie. text, images, divs, whatever you want). For an example, roll your mouse over the donuts or Taco’s yearning face and you’ll see that the photos appear to “lighten”, but really, it’s just more of my white background showing through. This is a neat trick — check out the screencast to see how you can use it on your sites.

Thanks for waking me from my 1990′s slumber, Alt!

Best viewed fullscreen, HD.

.change_opacity:hover{

/* FIRST (order is important) */
opacity: 0.8;

/* SECOND (IE8) */
-ms-filter:”progid:DXImageTransform.Microsoft.Alpha(Opacity=80)”;

/* THIRD (IE7) */
filter: alpha(opacity=80);
}

Need a CSS review? Check out my Web Basics tutorials. How about a Firebug review? I used Firebug in these screencasts: Banish Drop Shadows, Horizontal Nav Bar Part 3.

Thanks for the IE fix, Quirksmode!

Songs by Allen Cote
♥··· fonts used in the screencast ··· ♥
ht gelateria from myfonts
cheap pine from myfonts
script bt
miso from font squirrel
verner from myfonts

{ 27 comments }  

1 sharon 08/04/2011 at 4:11 pm

that’s very cool. thanks for sharing (:

2 Windsor Grace 08/04/2011 at 5:57 pm

Thank you so much for posting these!

3 Dolly Pop! 08/04/2011 at 7:01 pm

Your blog is such a big help. I follow you via bloglovin, and I always click on the “like” button so I’d know easily where to find you.

Love,
Nini

4 knitxcore 08/04/2011 at 7:01 pm

i love your tutorials, and by proxy mr. allen cote.
he’s sort of a babe. haha.

5 Allison Suter 08/05/2011 at 5:21 am

Thank you so much! In the middle of the night last night I was thinking that a button on my website needed a little “je ne sais quoi”, but it was late and I decided to sleep on it. Low and behold, in my Google Reader this morning your sweet sweet tutorial! And the perfect inspiration for not only my button, but my logo as well! Thanks again!

6 liliestfolle 08/05/2011 at 5:58 am

Awesome! i’ve just used your tutorial for my sidebar and this is perfect!! Thanks Miss, you’re the best! :)

7 Marilyn 08/05/2011 at 11:23 am

This is pretty neat, I may try to incorporate this in my site :)

8 Anilu Magloire 08/05/2011 at 2:43 pm

Love this! So easy and I always wondered how to do this.
Thank you for another amazing tut :-)

9 Katrina 08/05/2011 at 3:00 pm

glad you guys like this! it’s perhaps one of the simplest things you can do to make your site a bit more visually engaging and “dynamic”.

@liliestfolle: EXCELLENT!

10 hannah 08/05/2011 at 4:15 pm

you are bomb lady! :D

11 Claudia 08/06/2011 at 1:20 am

Just have to tell you – I LOVE the music in this video.
And your tips are so inspiring. I will have to start a blog just so I can have fun with all of your tutorials – and show my results to the world :)

12 Anilu Magloire 08/06/2011 at 9:25 am

OMG, I love the slider, Katrina. Looks so cool. Pugly gets better and better :-)

13 Katrina 08/06/2011 at 9:55 am

Aaaah, you noticed the slider! Thanks, Anilu.

14 Cesar 08/08/2011 at 2:07 am

that is one cute pug

15 Hester 08/08/2011 at 2:08 am

First of all, totally addicted to your blog!

Secondly, I’m sure this is a very silly question, but is there an HTML equivalent?

16 Katrina 08/08/2011 at 7:58 am

@Hester: wow, thanks, hester. :) to address your 2nd Q: sorry, no HTML equivalent.

17 Merissa 08/08/2011 at 7:05 pm

I just have to say that Taco should get a donut. I mean, look at that face. I’d totally give in (^•^) And those are the prettiest vegan donuts I’ve seen. Yum!

18 Mary Beth|Cupcakes and Crinoline 08/09/2011 at 7:01 am

I just found you yesterday and I may never leave…everything is so beautiful and I am excited to try the tutorials. :)

19 Vicki 08/09/2011 at 8:38 am

Hey Katrina, Love your blog! I tried this on one of my posts… easy peasey. Thanks to your tutorial! I am sharing this on our blog today. Hope you don’t mind the free PR! Sidenote: my son, Adam, starts college in less than 20 days at Columbia College. He is very excited!! So, glad to know the college graduates smarty pants like you. ;)

20 karla porter archer 08/09/2011 at 1:52 pm

such a simple thing with such an impact!

do you still plan on doing a tutorial on the hover like you have in your nav menu?

21 Katrina 08/09/2011 at 3:02 pm

@karla: hi karla — yes! :D i kinda got sidetracked, but yes, that’s the plan — please stay tuned.

@vicki: THANK YOU. :D

22 karla porter archer 08/10/2011 at 11:25 am

oh happy day!!! :) I’ve been looking forward to that one — I’ve made them for developers to use in sites, but have never learned the coding aspect of it.

*happy dance*

23 Claire 08/14/2011 at 7:44 am

What a lovely little tip. Simple, classic effect, but adds a nice touch of elegance. Thank you!!

24 Lisa (sideoats + scribbles) 08/18/2011 at 10:48 am

Oh Katrina, thanks so much for doing this tutorial! I just tried it, worked great! Love nifty little things like this that you find for us. :)

25 Lisa (sideoats + scribbles) 08/18/2011 at 10:49 am

Oh and YUM on the donuts! I had my first vegan donut not to long ago and I agree — one of the best donuts I’ve ever had! Just yum. :)

26 Jodie 09/11/2011 at 4:39 pm

Yay, I did it! I’m not sure I like the faded effect though. Is there a way to make it actually greater opacity, if that makes sense? Instead of lesser opacity when you roll over it, will a 120% opacity work?

what is firebug and how does it work, how do you download it? I went to firebug.com but couldn’t really figure out what I need.

27 Katrina 09/13/2011 at 10:41 pm

@jodie: 100% is max. and, you can learn more about firebug here.

Previous post:

Next post: