Transparent Image in CSS

How to make image transparent in current and previous versions of browser and creating hover effect with it.

Opacity property can be used in new versions of all major browsers but previous versions can not handle this property. It can take value from 0.0 to 1.0 each point add 10% of opacity.

1
2
3
4
5
6
7
img {
      opacity:0.5;
      filter:alpha(opacity=50);
}

It is this simple to define, filter:alpha is used for older versions of browsers which doesn’t support opacity property. We can create effects with opacity as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
img {
      opacity:0.5;
      filter:alpha(opacity=50);
}
img:hover {
           opacity:1.0;
           filter:alpha(opacity=100);
}

We have created the hover effect with opacity control, on hovering image will change its opacity to 100%.

Example

Hover your mouse cursor on upper image to see transparency affect.

Final Code (CSS)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<style>
img {
      opacity:0.5;
      filter:alpha(opacity=50);
}
img:hover {
           opacity:1.0;
           filter:alpha(opacity=100);
}
</style>

Final Code (HTML)

1
<img src="/images/logo.png" />


Related posts

Tags: , , , , ,

No Response

Post your response

Copyright © 2010 - 2013 Handy CSS Designed By Anotix, Powered By WordPress, all right reserved.