0

Title says it all, I want to have the background at 50% opacity and the outline non-transparent.

div
{
opacity:0.5;
Border:1px solid #000000;
background-color:#000000;
}

Any help is appreciated.

Makkebakke
  • 19
  • 1
  • 5

2 Answers2

3

Use rgba

the a is for opacity of the background... which can be 0 through 1 , 0 is invisible, 1 is fully visible..

div {
   background-color: rgba(0,0,0,.5);
   border: 1px solid black;
}
CRABOLO
  • 8,605
  • 39
  • 41
  • 68
1

setting opacity will automatically set anything related to that class, including outline and even child nodes.

You can use rgba() to make a semi-transparent background color.

like this:

background-color:#000000; //fall-back for old browsers that don't support rgba
background-color: rgba(0,0,0,0.5); //set background color. red=0, green=0, blue=0, alpha=0.5

http://css-tricks.com/rgba-browser-support/

TastySpaceApple
  • 3,115
  • 1
  • 18
  • 27