Box-shadow over border

Problem

I have this problem where I want to have a border and a box-shadow, but the shadow must be over the border.

The box-shadow property starts when the border ends, is it possible to move it over the border?

.border
{       
    border: solid rgba(128,42,42,.98) 16px;
}


.img-box-shadow
{
    -moz-box-shadow: 0px 0px 20px #000000;
    -webkit-box-shadow: 0px 0px 20px #000000;
    box-shadow: 0px 0px 20px #000000;
}

My HTML:

<img class="border img-box-shadow" src="img.png">

Already tried inset in my box shadow, but it didn't work!

I'm looking for this effect:

border

And I'm getting this result:

shadow in border

Problem courtesy of: Mandi

Solution

I think this would be much more easily achieved with two overlayed box shadows

Something like this approaches what you're looking for

box-shadow: 0 0 20px 5px #000000,
    0 0 0 16px rgba(128,42,42,.98);
Solution courtesy of: Zach Saucier

Discussion

You can try using inset and then lowering the alpha value of your border. It may not exactly be what you want, but it's close.

.border
{       
    border: solid rgba(128,42,42,.5) 4px;
}


.img-box-shadow
{
    -moz-box-shadow: inset 0px 0px 20px #000000;
    -webkit-box-shadow: inset 0px 0px 20px #000000;
    box-shadow: inset 0px 0px 20px #000000;
}

Alternate option (borrowed from this question). Don't use the .border and just use this (you can play around with pixel values):

.img-box-shadow
    {
        box-shadow: rgba(0,0,0,.98) 0px 0px 3px, inset rgba(0,0,0,.98) 0px -2px 3px;
    }

Here's a JSFiddle

Discussion courtesy of: JLewkovich

Seem like you want an inset box shadow, then you can use:

box-shadow: inset 0 -15px 10px -10px #444;
-moz-box-shadow: inset 0 -15px 10px -10px #444;
-webkit-box-shadow: inset 0 -15px 10px -10px #444;

Fiddle Demo

Discussion courtesy of: Felix

How about this one?

.ds-bottom {
  position:relative;
  overflow:hidden; 
  border-bottom:1px solid #ddd; 
}
.ds-bottom:before {
  content: ""; 
  position:absolute; 
  z-index: 1; 
  width:96%;  
  bottom: -10px; 
  height: 10px; 
  left: 2%; 
  border-radius: 100px / 5px; 
  box-shadow:0 0 18px rgba(0,0,0,0.6); 
}
Discussion courtesy of: fxdavidd

First, you have mistake in box shadow format.

 box-shadow: 0px 0px 20px #000000;

Change to

box-shadow: 0px 0px 20px 0 #000000;

Due to the right format of Box Shadow Properties

box-shadow: horizontal-length vertical-length blur-radius spread-radius;

Next, to make it works with your requirement you must wrap your image inside div. Box-shadow wont works over border.

Here's the style

div { 
  display:inline-block;
  padding:4px; /* Act as border width */
  background:rgba(128,42,42,.98); /* Act as border color */
}

.img-box-shadow
{
  box-shadow: inset 0px 0px 20px 0 #000000;
  -webkit-box-shadow: inset 0px 0px 20px 0 #000000;
  -moz-box-shadow: inset 0px 0px 20px 0 #000000;
}

And the HTML Markup

<div class="img-box-shadow">
<img src="http://graph.facebook.com/715380382/picture?type=large">
</div>

Check live demo http://jsbin.com/hex/1/edit

Discussion courtesy of: cutez7boyz

This recipe can be found in it's original form on Stack Over Flow.