Dropshadow with css

user952691 picture user952691 · Oct 2, 2011 · Viewed 46.1k times · Source

I want to add a transparent dropshadow to my div. I have a container, and behind it I want to place a dropshadow. I don't want the dropshadow to have a color. This is what I have so far:

.content_right1{

    background:#fff;

    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
     border-radius:10px;

    -moz-box-shadow: 5px 5px 5px #99CCFF;
    -webkit-box-shadow: 5px 5px 5px #99CCFF ;
     box-shadow: 5px 5px 5px #99CCFF;

    /* other styles of the class */
    width:380px;
    float:left;

    margin-left:3px;
    padding:15px;

    min-height:450px;
    margin-left:15px;
}

I want to add the opacity, but when I do the opacity of the whole div changes.

Answer

Darklg picture Darklg · Oct 2, 2011

If you want a dropshadow with a level of opacity, you should use rgba() for its shadow color :

http://css-tricks.com/2151-rgba-browser-support/

edit:

-moz-box-shadow:5px 5px 5px rgba(0,0,0,0.3);
-webkit-box-shadow:5px 5px 5px rgba(0,0,0,0.3);
box-shadow:5px 5px 5px rgba(0,0,0,0.3);