How to Apply Opacity/Transparency in CSS3

The opacity or transparency is a new effect in CSS3. Designers are really in the early stages of experimenting with this effect. In CSS3, transparency is defined by assigning a value to the opacity property. A fully opaque object completely obscures whatever is behind it; objects that aren’t fully opaque are partially see-through, or transparent.

Defining semitransparent backgrounds for page layout elements with CSS3 presents some exciting options for web designers. Semitransparent backgrounds are often used, for example, in drop-down lists. There, the drop-down menu elements have .5 opacity assigned (they are 50 percent transparent). As a result, the underlying page content remains visible when a menu drops down.

image0.jpg

The opacity property is defined with a value ranging from 0 (completely invisible) to 1 (fully opaque; not transparent at all). So, for example, an opacity value of .8 makes an object 80 percent opaque, and so on.

The opacity property does not require prefixes for different browsers. The syntax is simple:

opacity: .x

The drop-down list shown, for example, is defined as such:

.menu_box {
      background-color: #999;
      padding: 2px;
      color: #333333;
      opacity: .5;
}
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.