Rounded Corners and Drop-Shadow Borders

Success! We have a good-looking rounded corner that works for both Firefox & IE (version 7 at least.) In digging for techniques, I found this nice index of possible rounded corner techniques at the CSS-Discuss mailing list site. If you are not already aware, CSS-Discuss is the premier mailing list if you are interested in leading-edge CSS information.

As the list is arranged in order from best to least browser support,  I decided to look through the ones at the top. One site name caught my eye… Roger Johansson’s  456 Berea St! I’ve found a lot of great resources there in the past, so that was my first, and last, stop. While the link on the CSS-Discuss page goes to an older version of the technique, it has been updated in the post, Transparent custom corners and borders, version 2. You may need to go back to the original post, and the one on customizing the graphics to help create your own. Thank you again, Roger!

This technique using JavaScript to adjust the DOM content of the document you want to add the borders to, thus not requiring heavy additional mark-up to the original document. I tried another technique earlier, that required adding additional <div>’s at the top & bottom where I wanted to the add the borders. It worked, but it wasn’t pretty! For this one, I simply have to reference the JavaScript file which is stored externally, add an additional CSS class to the <div> I want to have borders on, and add the CSS. Done! Well, almost. You do need to create the graphic used for the border. I think I spent more time on that than I did anything else! I’m not a graphic designer, so I don’t usually do ‘fancy stuff’ with graphics. So, it took me a couple tries to get what I wanted. I also am using the border technique a little differently than Roger shows.

In Roger’s examples, he is using a light background, so using the drop-shadow boder with transparency works nicely. However, in my case, the background is dark, so the drop-shadow style doesn’t work well, so I switched to an ‘internal shadow’, with a hard external border. This was important, as I had to add the background color to each corner of the graphic, otherwise the light background color would extend outside the box, squaring it off again. If it was a light color internal & external, this would not have been necessary. Here’s the two graphics I used:

The Box

[image no longer available.]

The borders:

[image no longer available.]

After adjusting the CSS for the height and width of the corners of the box, and the width of the left & right sides of the borders, it worked like a charm. In case you are not familiar with it, this uses the ‘sliding doors’ technique–as described by Douglas Bowman at A List Apart (another good site to watch!)–to use only two graphics to get all the pieces you need for the corners, as well as the sides of the box. Here’s the result:

[image no longer available.]

And here it is in IE:

[image no longer available.]

You can only tell them apart by the tabs now. As you may guess, that’s the next place this technique will be applied!