Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw realistic smooth slit shadow with Pure CSS3?

Tags:

css

How can I make a shadow effect like the one below with pure CSS?

Shadow Effect

I am new to CSS. The following is what I have tried so far, but I am unable to come close to what I want. Please advise how I can make it look like the shadow in the image? Thanks!

box-shadow: 1px 1px 5px #999999 inset
like image 690
ariel Avatar asked Dec 15 '13 15:12

ariel


1 Answers

This is the closest I could get : Demo. I think it's actually not bad.

Pure CSS smooth paper-side shadow effect

It combines a black shadow and a white one on top of it.

.yourclass{
    background-color: #fff;
    box-shadow:  -15px 0px 60px 25px #ffffff inset, 
        5px 0px 10px -5px #000000 inset;
}

Browsers' shadows smoothing might differ. I'm using chrome so you might want to tweek the values to get a cross-browser visual effect...

Read the CSS Tricks article about box-shadows to get how they're used.

For two shadows (both sides) you need 4 shadows (demo) :

Result:

Pure CSS smooth paper-side shadow effect

.yourclass{
    background-color: #fff;
    box-shadow:  0px 100px 50px -40px #ffffff inset,
        0px -100px 50px -40px #ffffff inset,
        -5px 0px 10px -5px rgba(0,0,0,0.5) inset,
        5px 0px 10px -5px rgba(0,0,0,0.5) inset;
}

Beware, browsers' shadows rendering/smoothing can differ a lot. I'm using chrome so you might want to tweek the values to get a cross-browser visual effect...

For more info on css shadows, read this article from CSS Tricks

like image 76
Armel Larcier Avatar answered Sep 22 '22 23:09

Armel Larcier