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>
Answer from BoltClock on Stack OverflowVideos
I used to hate my box-shadows, before I discovered the magic behind others. A lot of you probably know this from before, but I still feel like sharing.
Instead of using 1 box-shadow, you use 2. The second one with bigger blur and .8 opacity.
Use a soft black for the first one.
X-axis = 0. Y-axis = 5-10px. Blur low, like 10px
Same color on 2nd, but lowered opacity.
X-axis = 0. Y-axis = 10px more than previous. Blur 40-50px.
Code goes something like this:
box-shadow: 0 5px 10px rgba(154,160,185,.05), 0 15px 40px rgba(166,173,201,.2);
Result
I've done graphic design for many years and this applies to anything you want to make a drop shadow for, it requires 4 layers but the effect is flawless in appearance.
Excellent tip for applying this to css.
sorry for picking nits, but you mentioned 0.8 opacity for the second one, and also "lowered opacity" for the second one.
I see 0.05 opacity for the first, and 0.2 for the second. What am I missing?