views:

104

answers:

2

What's the best practice for creating drop shadows around html where the html can be liquid?

I used to use a table and have 8 png images (4 sides and 4 corners) as backgrounds for each of the outer 8 cells with the html I want the drop shadow around in the middle cell. Not very semantic, but at least the drop shadow imagery were backgrounds and it was liquid... html was ugly, tedious and maybe not very SEO friendly.

Is there a more compatible (though I don't remember having browser issues at all) way now or is there a more semantic way of handling this?

I don't care about IE6. I use jquery, so a javascript/jquery mechanism, as long as there are no compatibility issues among modern browsers, is fine with me.

UPDATE: the suggestion to use CSS3's box-shadow was excellent. The only problem is it does a box shadow only the same size as the html element it's applied to. So this means that I can't have a drop shadow all around (as if a light source is directly overhead). I could add a surrounding div that's a little bigger. But then what happens is the border-radius causes white artifacts to appear at the corners...

Is there a way to have a nice black shadow all the way around an html element, not just offset from it?

UPDATE 2: CSS3's box-shadow and firefox/webkit's implementation all support a spread value that allows for what I want. Wasn't in that dynamicdrive.com link below.. Thanks guys!

+5  A: 

Ignore IE7/8 and use the box-shadow CSS3 rule. Lack of shadows isn't the end of the world on these legacy browsers. If it is, then charge for it accordingly. You could also investigate IE's proprietary dropshadow filters, and see if the result is reasonable.

More resource: here

w3c working draft definition: here

danp
I can ignore IE6, but not 7 and 8... Looks like this is the way to go though. What's the best IE7/8 CSS3 shadow emulator?
at
Maybe a combination of blur and drop shadow filters in IE will work, but in truth, I'd just do basic support in IE with normal transparent PNG's.. if it's absolutely necessary. I kludged support with a massive height single image PNG for IE, but it depends on the complexity of your design.
danp
CSS3 definitely seems like the way to go and I guess IE7/8 users can deal with a non-blurred drop shadow. But the problem is described in my update above.
at
A: 

You could try the plugin for jQuery Drop Shadow.

It does have a bit of a performance hit though and takes an age on multiple elements on slower client machines. For our company site I just used the CSS3 route which obviously didn't work in IE but anyone with any taste uses FF anyway :). Lots of big sites such IGN take the similar approach that if the client can support CSS3 shadows then great otherwise tough cheese.

Paulie Waulie