2

How to set the opacity of the border?

I want it to be transparent so that objects behind the border will be seen.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
smz
  • 51
  • 2
  • 6

5 Answers5

2

Try this,

border-color: rgba(0,0,0,0.5); // 50% opacity

The last value varies from 0 to 1. Where 0 is completely transparent and 1 is Opaque.

Sarvap Praharanayuthan
  • 4,212
  • 7
  • 47
  • 72
1

I think something like this should do the trick:

border: 10px solid rgba(255, 255, 255, 0.5);

More info: http://www.css3.info/preview/rgba/

Joren
  • 3,068
  • 25
  • 44
0

You can use rgba format in modern browsers.

border: 2px solid rgba(0, 51, 255, 0.5)

You can use it in all modern browsers. Here's a list

Jashwant
  • 28,410
  • 16
  • 70
  • 105
0

You Can't Do it. because the "objects behind the borders" is the object itself.

check this Fiddle

Tomzan
  • 2,808
  • 14
  • 25
0

Choose any CSS colour function with an alpha channel:

rgba(RR, GG, BB, ALPHA) or hsla(HUE, SAT, LUM, ALPHA)

The alpha value is between 0 and 1.

You may also want to have a look into background-clip property for defining the position of the background in relation to the box-model of the element.

kumarharsh
  • 18,961
  • 8
  • 72
  • 100