Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to do curved shadows

Tags:

html

css

slice

For something like this:

box

What would be the most effective way to do this? Best to do an image, or is there a way to achieve this with CSS without a bunch of hacks/extra markup that I dont know about?

Also the shadow only has to work in IE9, FF, and Chrome

like image 658
Oscar Godson Avatar asked Dec 02 '11 00:12

Oscar Godson


Video Answer


1 Answers

You would do so using pseudo-elements and the box-shadow property. I have done up an example for you here: http://jsfiddle.net/joshnh/NWnXw/

This works in IE9 and up.

/* Shadow */

.shadow {
    box-shadow: 0 1px 5px hsla(0,0%,0%,.25),
                inset 0 0 50px hsla(0,0%,0%,.05);
    position: relative;
}
.shadow:after,
.shadow:before {
    bottom: 7px;
    box-shadow: 0 10px 15px hsla(0,0%,0%,.25);
    content: '';
    height: 50%;
    left: 7px;
    max-width: 300px;
    position: absolute;
    right: 7px;
    z-index: -1;
    -webkit-transform: skew(-15deg) rotate(-8deg);
       -moz-transform: skew(-15deg) rotate(-6deg);
        -ms-transform: skew(-15deg) rotate(-6deg);
         -o-transform: skew(-15deg) rotate(-6deg);
            transform: skew(-15deg) rotate(-6deg);
}
.shadow:after {
    -webkit-transform: skew(15deg) rotate(8deg);
       -moz-transform: skew(15deg) rotate(6deg);
        -ms-transform: skew(15deg) rotate(6deg);
         -o-transform: skew(15deg) rotate(6deg);
            transform: skew(15deg) rotate(6deg);
}
like image 145
joshnh Avatar answered Sep 28 '22 07:09

joshnh