Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

CSS DIV with Cross Browser Opaque Border with Solid background

CSS DIV with Cross Browser Opaque Border with Solid background

Problem

Is it possible to achieve cross browser (ie6+) semi-transparent borders with a solid background on div?

I have only found instances where:

  • Borders are semi-transparent, but so is background.
  • Body is semi-transparent, but borders are not.

Can anyone point me in the right direction, or an alternative solution?

Problem courtesy of: c0D3l0g1c

Solution

This depends on which browsers you want/have to support, but you can use the CSS3-rgba declaration to define colors (standard rgb with additional a - which is the alpha/transparency channel). Also, depending on the colors of the background and border, you might need to add the background-clip property.

rgba(255,255,255,.5);
background-clip:padding-box;

would give you an 50% opaque white. This works on every attribute you can specify a color on.

It's pretty good supported with the (how surprising) exception of IE

Here is an example for you: transparent border with solid bg.

For the sake of completeness: The necessary background-clip has the same browsersupport, but here is a browser support table

EDIT:

For support for IE6+ you should take a look at CSS3Pie. It emulates CSS3 Properties like rounded corners or other color spaces via VML.

Solution courtesy of: Christoph

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

CSS DIV with Cross Browser Opaque Border with Solid background

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×