1

How to set the opacity of the border?

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

BenMorel
  • 31,815
  • 47
  • 169
  • 296
smz
  • 41
  • 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,025
  • 7
  • 46
  • 70
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
  • 2,914
  • 19
  • 42
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
  • 27,289
  • 16
  • 69
  • 100
0

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

check this Fiddle

Tomzan
  • 2,738
  • 13
  • 24
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,026
  • 7
  • 71
  • 97