Your only option is to use multiple box-shadows. However, there are some restrictions:
- You must use a semi-opaque colour, because they will show through each other.
- You have to manually specify each box-shadow property, but you can do it programatically with either JS, or with a CSS pre-processing language (e.g. LESS or SASS).
div {
background-color: steelblue;
box-shadow:
2px 2px 5px 0px #555,
4px 4px 5px 0px #555,
6px 6px 5px 0px #555,
8px 8px 5px 0px #555,
10px 10px 5px 0px #555,
12px 12px 5px 0px #555,
14px 14px 5px 0px #555,
16px 16px 5px 0px #555,
18px 18px 5px 0px #555,
20px 20px 5px 0px #555,
22px 22px 5px 0px #555,
24px 24px 5px 0px #555,
26px 26px 5px 0px #555,
28px 28px 5px 0px #555,
30px 30px 5px 0px #555,
34px 34px 5px 0px #555,
36px 36px 5px 0px #555;
width: 100px;
height: 100px;
}
<div></div>
I have also made an example using SCSS: http://codepen.io/anon/pen/WvELEv
You can set the opacity of the shadow, by using a pseudo-element instead:
- Use
position: relative
on the parent, and position the pseudo-element absolutely
- Force pseudo-element to have the exact same dimension as its parent, by setting all for cardinalities to 0
- Apply
box-shadow
property to pseudo-element
- Instead of changing the
background-color
to use the rgba()
channel, use opacity
to control transparency instead.
body {
background-color: yellow;
}
div {
background-color: steelblue;
width: 100px;
height: 100px;
position: relative;
}
div::before {
opacity: 0.25;
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
box-shadow: 2px 2px 5px 0px #555, 4px 4px 5px 0px #555, 6px 6px 5px 0px #555, 8px 8px 5px 0px #555, 10px 10px 5px 0px #555, 12px 12px 5px 0px #555, 14px 14px 5px 0px #555, 16px 16px 5px 0px #555, 18px 18px 5px 0px #555, 20px 20px 5px 0px #555, 22px 22px 5px 0px #555, 24px 24px 5px 0px #555, 26px 26px 5px 0px #555, 28px 28px 5px 0px #555, 30px 30px 5px 0px #555, 34px 34px 5px 0px #555, 36px 36px 5px 0px #555;
}
<div></div>