The simplicity of a css technique by Ryan Thrash about Rounded Corners for CSS Boxes appealed to me. This technique uses a single image to build all four corners of a box. It's a bit like using a piece of wrapping paper to wrap a gift. The paper overlaps a bit as you fold it over, but as long as it is big enough it works fine. Sure it is a little inefficient; the full image file size is bigger than the optimized and sliced-up background images would be, but since it's cached by the browser it only has to load once.
But that fixed size did cramp my style eventually. I wanted to make boxes around content which could expand vertically as much as needed with no worries that I'd run out of wrapping paper. So I made a modification to allow boxes of arbitrary height. It required another image which would repeat in the middle section, and two more html element 'hooks': I opted to add a right body div and a footer div. The general patten is that the outer divs hold the right side of the background and the interior divs hold the left side. The code looks like this:
.cssbox, .cssbox_head, .cssbox_head h3, .cssbox_footer { background: transparent url(images/cssbox.png) no-repeat top right; } .cssbox_bodyL, .cssbox_bodyR { background: transparent url(images/cssbox_stretch.png) repeat-y right; } .cssbox { width: 535px !important; /*intended total box width - padding-right(next) */ width: 550px; /* IE Win = width - padding */ padding-right: 15px; /* the gap on the right edge of the image (not content padding) */ margin: 0px auto 5px auto; /* use to position the box */ } /* set the top-right corner */ .cssbox_head { background-position: top right; margin-right: -15px; /* pull the right image over on top of border */ padding-right: 320px; /* right-image-gap + right-inside padding */ } /* set the top-left corner */ .cssbox_head h2 { background-position: top left; margin: 0; /* reset main site styles*/ padding: 6px 0pt 12px 6px; /* padding-left = image gap + interior padding ... no padding-right */ height: auto !important; height: 1%; /* IE Holly Hack */ } /* set the right side */ .cssbox_bodyR { margin-right: -15px; } /* set the left side */ .cssbox_bodyL { background-position: left; padding: 0 10px 12px 10px; /*compensate for the footer slideup*/ margin: 0px 15px 0 0; } /* set the lower-left corner */ #cssbox_footer { background-position: bottom left; margin-right: 25px; /* interior-padding right */ padding: 0 0px 15px 0px; /* mirror .boxstyleA_head right/left */ }