2
votes

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!

2

2 Answers

7
votes

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

1
votes

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.