Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set transparency in CSS3 box-shadow?

Tags:

css

Is it possible to set transparency on the box shadow?

This is my code:

  box-shadow:10px 10px 10px #000;   -webkit-box-shadow:10px 10px 10px #000;   -moz-box-shadow: 10px 10px 10px #000; 
like image 534
Steven Avatar asked Mar 28 '11 12:03

Steven


People also ask

How do you blur a box shadow in CSS?

That syntax is: box-shadow: [horizontal offset] [vertical offset] [blur radius] [optional spread radius] [color]; The horizontal offset (required) of the shadow, positive means the shadow will be on the right of the box, a negative offset will put the shadow on the left of the box.

Is Box shadow supported by CSS?

This property is partially supported in Chrome from version 4 to 9, using the prefix -webkit- , and it's fully supported from version 10. For Mozilla Firefox, versions 2 and 3 do not support CSS box-shadow . It's partially supported on 3.5 and 3.6 using the -moz- prefix and fully supported from version 4.


1 Answers

I suppose rgba() would work here. After all, browser support for both box-shadow and rgba() is roughly the same.

/* 50% black box shadow */ box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5); 

div {      width: 200px;      height: 50px;      line-height: 50px;      text-align: center;      color: white;      background-color: red;      margin: 10px;  }    div.a {    box-shadow: 10px 10px 10px #000;  }    div.b {    box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5);  }
<div class="a">100% black shadow</div>  <div class="b">50% black shadow</div>
like image 90
BoltClock Avatar answered Sep 17 '22 08:09

BoltClock