views:

36

answers:

3

Howdy!

I'm designing a page that has a Content Area which scales against a diagonally striped background.

The Content Area div is a fixed width that will scale vertically with content. Because the border is a drop shadow, I have a repeating background image (40px wide by 80px high) that has to line up with the page background image. I need the div to scale in multiples of 80px high so that the repeating backgrounds concur with each other.

Is there an elegant solution that will allow me to scale the Content Area div so that it always displays at a multiple of 80px high? If not, is there another approach I can take to solving this problem rather than scaling the div to a multiple of 80px?

Thanks in advance!

Ryan

+2  A: 

Unless you absolutely need the drop shadow to appear in older browsers, you can generate it with the CSS3 box-shadow property instead of using an image. This is much more flexible as the shadow is generated by the browser and will fall nicely on the background regardless of how things line up.

Jimmy Cuadra
Well, I'm not sure that property's going to do what I need it to do. If you want, why don't you take a look at what I'm working with:http://www.prettysmartstudios.com/psstest/web.htmlThanks!
Ryan Stolte-Sawa
As this page states http://www.bloggingcss.com/en/tutorials/css3-box-shadow-property/ , box-shadow is still not widely supported, so (too?) many users won't see them.
Marcel Korpel
Yes, browser compatibility is another concern, thanks Marcel.
Ryan Stolte-Sawa
Ah yes, I see that box-shadow may not work due to the zig-zag pattern on the top and bottom edges. Another solution would be to use JavaScript to increase the height of the element to the next nearest multiple of 80. This isn't ideal because it's using JavaScript to control presentation and leaves the display potentially broken when JavaScript is turned off or unavailable. Just something to consider, though.
Jimmy Cuadra
Jimmy, that's something I was considering as well. For the sake of speed, at this point, I'm considering transparent pngs. It's kind of six of one, half a dozen of the other, isn't it?
Ryan Stolte-Sawa
+1  A: 

Jimmy's idea is solid, assuming the browser supports this css property. Another, weirder idea to consider might be to have jquery insert a div into the DOM that has fixed positioning and is offset to your content div and a z-index that would put it behind your content div. Then you could this new under-div an opacity (you can use fadeTo but maybe there's something better). Basically give the content div a real shadow by having an identically sized div underneath with 50% opacity.

Anthony
Thanks for the feedback, Anthony. That's an interesting idea...definitely a trick I'll keep in mind.
Ryan Stolte-Sawa
A: 

why dont you leave the stripped background out of the content areas and use a transparent png for the images that will use a drop shadow. Since you're already trying to use javascript to fix a css problem, why not use DD_belatedPNG so that the alpha transparency will display correctly in IE6

iangraham
You win, Ian. I think this is the simplest solution. Thanks for the JS fix info, too. Cheers!
Ryan Stolte-Sawa