Search code examples
cssdropshadow

How can I make a fancy drop shadow?


I have an "article" tag and I want to make it have a fancy drop shadow with lifted corners. I want to avoid using images and make it purely with CSS if possible at all.

This is an example of something that looks like what I want to achieve:

Here is my code:

<div class="mainContent">
    <div class="contentWrapper">
        <article class="content">

        </article>
    </div>
<div>

And the CSS I have so far:

.mainContent{
background: #F8F8F8;
width: 100%;
position: absolute;
margin-top:500px;}

.contentWrapper {
margin: auto;
width: 1000px;
padding-top: 50px;}

.content {
margin-bottom: 50px;
padding: 40px;
border: #999 1px solid;
line-height: 25px;
color: #4D4D4D;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
background-color: #FFF;
box-shadow: 0px 0px 1px 1px #e1e1e1 inset, 0px 23px 30px -33px #4D4D4D;}

Solution

  • Add the css below to a simple div like <div class="shadow lifted"></div>

    .shadow {
    position:relative;
    width:40%;    
    padding:1em; 
    margin:2em 10px 4em; 
    background:#fff;
    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
       -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
            box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
    }
    
    .shadow:before,
    .shadow:after {
    content:"";
    position:absolute; 
    z-index:-2;
    }
    
    
    .lifted {
    -moz-border-radius:4px; 
         border-radius:4px;
    }
    
    .lifted:before,
    .lifted:after { 
    bottom:15px;
    left:10px;
    width:50%;
    height:20%;
    max-width:300px;
    -webkit-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);   
       -moz-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
            box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
    -webkit-transform:rotate(-3deg);    
       -moz-transform:rotate(-3deg);   
        -ms-transform:rotate(-3deg);   
         -o-transform:rotate(-3deg);
            transform:rotate(-3deg);
    }
    
    .lifted:after {
    right:10px; 
    left:auto;
    -webkit-transform:rotate(3deg);   
       -moz-transform:rotate(3deg);  
        -ms-transform:rotate(3deg);  
         -o-transform:rotate(3deg);
            transform:rotate(3deg);
    }
    

    DEMO