198

I'm trying to replicate a button style in a Photoshop mock-up that has two shadows on it. The first shadow is an inner lighter box shadow (2px), and the second is a drop shadow outside the button (5px) itself.

enter image description here

In Photoshop this is easy - Inner Shadow and Drop Shadow. In CSS I can apparently have one or the other, but not both at the same time.

If you try the code below in a browser, you'll see that the box-shadow overrides the inset box-shadow.

Here's the inset box shadow:

box-shadow: inset 0 2px 0px #dcffa6;

And this is what I would like for the drop shadow on the button:

box-shadow: 0 2px 5px #000;

For context, here's my full button code (with gradients and all):

button {
 outline: none;
 position: relative;
 width: 160px;
 height: 40px;
 font-family: 'Open Sans', sans-serif;
 color: #fff;
 font-weight: 800;
 font-size: 12px;
 text-shadow: 0px 1px 3px black; 
 border-radius: 3px;
 background-color: #669900;
 background: -webkit-gradient(linear, left top, left bottom, from(#97cb52), to(#669900));
 background: -moz-linear-gradient(top, #97cb52, #669900);
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#97cb52', endColorstr='#669900');
 box-shadow: inset 0 2px 0px #dcffa6;
 box-shadow: 0 2px 5px #000;
 border: 1px solid #222;
 cursor: pointer;
}
Richard Peck
76.8k9 gold badges98 silver badges148 bronze badges
asked Dec 19, 2011 at 2:41

2 Answers 2

490

You can comma-separate shadows:

box-shadow: inset 0 2px 0px #dcffa6, 0 2px 5px #000;
rxgx
5,1682 gold badges37 silver badges43 bronze badges
answered Dec 19, 2011 at 2:46
Sign up to request clarification or add additional context in comments.

2 Comments

Also mention that the first declared shadow is on to of the following one(s) jsfiddle.net/webtiki/s9pkj
You're missing the spead radius btw; that can make quite a difference. Also the opacity on the shadow really can make a difference. You can play with box shadows if you open dev tools here on my blog entry. fullstack.life/css3-multiple-box-shadows.html
25

Box shadows can use commas to have multiple effects, just like with background images (in CSS3).

answered Dec 19, 2011 at 2:45

3 Comments

While you can apply multiple shadows, applying inset shadows, I've found, is a special case. (But then that case only applied to images, I guess).
Really? I'm on mobile at the moment so I can't check; but I'd not heard that reported before...I'll look into that, tomorrow, after work. =/
If you want an inset shadow on an image you have to set an element or pseudoelement on top. It can be tricky.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.