/ Published in: CSS
URL: http://www.dubbelj.nl/drop-shadow/
As seen in maps.google.nl. Drop Shadow without any images. 5 DIV's with different opacity creates the gradient/shadow like effect. Lightweight and no png (or any IE6 hacks for that matter) hacks.
Any improvements are welcome...
Expand |
Embed | Plain Text
#north {position: absolute;width: 200px;left: 100px;top: 100px;height: 5px;} #east {width: 5px;position: absolute;height: 200px;top: 100px;left: 100px} #south {position: absolute;width: 200px;height: 5px;left: 100px;top: 302px;} #west {width: 5px;position: absolute;height: 200px;top: 100px;left: 305px} .ds_ch {height: 1px;line-height: 1px;width: 100%;background: black;display: block;overflow: hidden;} #east .ds_ch, #west .ds_ch {width: 1px;height: 100%;float: left;clear: none;display: inline;} .o1 {opacity: .5;filter: alpha(opacity=50);} .o2 {opacity: .4;filter: alpha(opacity=40);} .o3 {opacity: .3;filter: alpha(opacity=30);} .o4 {opacity: .20;filter: alpha(opacity=20);} .o5 {opacity: .10;filter: alpha(opacity=10);} /* For connecing the shadow in 2 corners */ .mv1 {margin-top: 0px;padding-bottom: 7px;} .mv2 {margin-top: 1px;padding-bottom: 5px;} .mv3 {margin-top: 2px;padding-bottom: 3px;} .mv4 {margin-top: 3px;padding-bottom: 1px;} .mv5 {margin-top: 4px;padding-bottom: 0px;} .m1 {margin-left: 1px;padding-right: 8px;} .m2 {margin-left: 2px;padding-right: 6px;} .m3 {margin-left: 3px;padding-right: 4px;} .m4 {margin-left: 4px;padding-right: 2px;} .m5 {margin-left: 5px;padding-right: 0px;} /* ds = dropshadow ch = child pa = parent o = opacity m = margin mv = margin vertical */ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="Author" content="#" /> <meta name="Description" content="#" /> <meta name="Copyright" content="#" /> <meta name="Robots" content="#" /> <meta name="Generator" content="#" /> <meta name="Keywords" content="#" /> <link rel="stylesheet" href="shadows.css" type="text/css" media="screen"/> </head> <body> <div id="north"> <div class="ds_ch o1 m1"> </div> <div class="ds_ch o2 m2"> </div> <div class="ds_ch o3 m3"> </div> <div class="ds_ch o4 m4"> </div> <div class="ds_ch o5 m5"> </div> </div> <div id="east"> <div class="ds_ch o5 mv5"> </div> <div class="ds_ch o4 mv4"> </div> <div class="ds_ch o3 mv3"> </div> <div class="ds_ch o2 mv2"> </div> <div class="ds_ch o1 mv1"> </div> </div> <div id="south"> <div class="ds_ch o5 m5"> </div> <div class="ds_ch o4 m4"> </div> <div class="ds_ch o3 m3"> </div> <div class="ds_ch o2 m2"> </div> <div class="ds_ch o1 m1"> </div> </div> <div id="west"> <div class="ds_ch o1 mv1"> </div> <div class="ds_ch o2 mv2"> </div> <div class="ds_ch o3 mv3"> </div> <div class="ds_ch o4 mv4"> </div> <div class="ds_ch o5 mv5"> </div> </div> </body> </html>
Comments
Subscribe to comments
You need to login to post a comment.

I like your use of north/east/south/west. I've always used top/right/bottom/left and it can get confusing in large stylesheets.
Thanks. I always use North, East, South and West in my mind when entering shorthand CSS for borders and padding. Makes it a lot easier to remeber which is which.
Well, I just couldn't help myself... Just wrote another drop shadow implementation: http://snipplr.com/view/8166/css-drop-shadow/
Just noticed you've got the id's for the east and west divs reversed ("east" should be "west" & vice versa).