Subscribe

RSS Feed | RSS Email | Twitter
 

Sponsors

 

Search / Categories

 

CSS3 RGBA

Posted on January 25th, 2009 by Zen Elements 2 Comments

CSS 3 RGBA Color Opacity

A straight forward guide to using the new CSS 3 ‘RGBA’ declaration, giving us not only the ability to set RGB color/colour as standard but also apply a level of opacity. There is also the quick + / – guide to which browsers support the herein effect.

The RGBA declaration sets color/colour as standard RGB does but the ‘a’ – the last value we apply in RGBA – allows us to set the level of opacity. Just as with the declaration for opacity, an element with opacity value 1.0 will be fully opaque (visible) while an element with opacity value 0.0 will be the complete opposite, invisible. Any value inbetween will determine how opaque (or transparent) the color is against its background.

Alert

Cross Brower Compatability
RGBA is currently better supported in FireFox, Google Chrome and Safari, also not requiring any prefix.
All articles in the CSS3 will be updated to show future support & development.

CSS 3 RGBA Color / Colour

The above RGBA example is set in another layer containing a completely random, never seen before background – kind of like the last article in Opacity… – and each layer uses the following CSS:

  1. CSS 3 Opacity (Example 1)
  2. div.L1 { background:rgba(153, 134, 117, 0.2); height:20px; }
  3. div.L2 { background:rgba(153, 134, 117, 0.4); height:20px; }
  4. div.L3 { background:rgba(153, 134, 117, 0.6); height:20px; }
  5. div.L4 { background:rgba(153, 134, 117, 0.8); height:20px; }
  6. div.L5 { background:rgba(153, 134, 117, 1.0); height:20px; }

Current Browser Support (Tested, Jan 2009)

  • FireFox (3.0.5)
  • Google Chrome (1.0.154.36)
  • Internet Explorer (IE6, IE7, IE8..)
  • Opera (9.6)
  • Safari (3.2.1, Windows)

An example for those on alternative browsers not seeing the different levels of opacity…

 

Zen Elements Blog | CSS3 Series

 

Thanks for reading,
Alex | Zen Elements


 
RSS
Facebook
StumbleUpon

Comments (2)

Chris KJanuary 30th, 2009 at 3:20 pm

Excellent stuff, thanks for this tip!

UlteriorMotivesJuly 23rd, 2009 at 8:42 am

Excellent series of little examples!

This one also works in Opera 10 Beta 2.

Leave a comment

Your comment

top
  • Zen Elements on Facebook
  • Zen Elements on Flickr
  • Zen Elements on Twitter
  • Zen Elements RSS Feed

© Zen Elements Ltd. 2008. All Rights Reserved. Sitemap | CSS | XHTML | Terms & Conditions