• Index
  • Archives
  • RSS Feed
  • WP Themes
  • Contact
  • Recent Posts

    • Visualizing Magnetic Fields. C...
      Posted Wednesday June 4th, 2008
    • Use Safari’s Activity Wi...
      Posted Friday May 30th, 2008
    • Peggle Is Very Addictive
      Posted Thursday May 29th, 2008
    • Mac App Idea: Finder Bar Twitt...
      Posted Tuesday May 27th, 2008
    • FWA Theater
      Posted Tuesday May 27th, 2008
  • Browse Posts

  • Links

    • seo
    • Affordable Web Hosting
    • Website Templates
    • Load Cells
    • MySpace Layouts
    • Envelope Seals
    • evden eve nakliyat
    • search engine optimisation
  • Site Sponsors

    • Megastar Media
    • Site5 Hosting

WebRevolutionary

Single Post

Fat Free CSS Drop Shadows

Posted Thursday March 27th, 2008 · See Comments

Most of the current publicized methods for implementing drop shadows in web design are far too excessive, some require wrapping the images in three extra divs, most rely on sliced images or sluggish javascript, but there’s a really simple method to add shadows to any block-level element without the need for any of this other faff, just pure, logical CSS.

As you’ll see in the examples, one can generate shadows of any width, in any colour and on any background. This technique is also rendered exactly the same in all browsers because, well, it’s just so simple (and simple solutions make me tingle).

Example: 2px Subtle Shadow

Example Image 1
img.shadow {
background: #afafaf;
padding: 1px;
border: 1px solid #d6d6d6;
}

Note that the above code is suited for this site’s background colour, I figuring out what colours to use before simply copying and pasting the code.

The logic behind this is quite simple, pad the element with 1 pixel of spacing to reveal its background colour (which is set to an appropriate shade of grey), then set the element’s border to a 1 pixel solid, lighter shade of grey. This gives a subtle (and in my opinion, good-looking) shadow effect, and won’t give you any headaches in the long run. I recommend using Photoshop to create a 3 pixel drop shadow on a layer (using your site’s background colour as the document background) and use this to reference your shadow colours.

If you’d like to see some more examples and take a look at the code, I’ve set up an Example Page. Using the methods documented there you can generate shadows of any size, even though I do believe the more subtle look is much nicer.

I’ve used this technique on a handful of client’s sites, even on dark backgrounds and it always works wonderfully, and since there’s no extra images, tricky javascript etc, you feel a lot cleaner when using this :)

This Post Has 7 Responses

  1. Brian Says:

    That’s pretty clever. lol

  2. Cori Says:

    Quite effective indeed. I’ll have to give this a try.

  3. Jacob Chapel Says:

    That is definitely simple and effective. Though aren’t drop shadows supposed to be on only two edges, like bottom and right?

    Although that is simple enough to do with your CSS example, just specify those edges on the padding and border.

  4. Matt Says:

    I agree with the above commenter, this seems more suited to doing a glow effect vs a drop shadow. Still, a simple and easy way to add a nice touch to your images.

  5. Bartek Says:

    Works like a charm! Nice and subtle and definitely “fat free” compared to all the other options out there :P

    Check it out in action! =]
    http://www.bmkphotoblog.com

    Thank you for this idea!
    Bartek

  6. Lawrence Says:

    Personally medium shadow is a little more me though - it’s less ‘oversubtle’ and seems to have less to hide.

  7. HMERT Says:

    Great tip! Simple and efficient. Thanks a lot.


Have Your Say, Leave a Comment