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;
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With