Victory Road Archive

You are viewing an archive of Victory Road.

Victory Road closed on January 8, 2018. Thank you for making us a part of your lives since 2006! Please read this thread for details if you missed it.

Technology → Cross Browser CSS Opacity

Page 1 of 1

1. FreezeWarp said on July 2, 2010, 05:25:09 AM (-07:00)

Kyurem
2,186 posts

CSS Opacity is fairly easy to achieve in all browser, including IE5.5+, Firefox, Opera, Safari, Google Chrome, Konqueror, Epiphany, ...you get the idea.

The main property is quite simply "opacity". This will give you opacity in every browser except IE (with the exception of IE9+). To deal with IE, we need two more properties; "filter" and "-ms-filter". The latter will work well in Internet Explorer 8, and the former in 5.5+. In the end, our code is:

Code:
selector {
  filter: alpha(opacity = 50); /* IE 5.5+ */
  -ms-filter: alpha(opacity = 50); /* Overrides the previous in IE 8 */
  opacity: .5; /* Overrides both of the previous in IE 9, works for all other browsers. */
}
And here is the demo:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget elit mi, sit amet cursus orci. Phasellus porta est sit amet turpis elementum ut congue lacus venenatis. Nulla lacinia tortor ipsum.


Many Javascript libraries, like jQuery, already use the technique for cross-browser support. Remember that general opacity is usually defined as a decimal or percent (say .5) while Internet Explorer opacity in a value out of 100 (say 50).

Page 1 of 1

User List - Contact - Privacy Statement - Lycanroc.Net