|
CSS 3: Rounding the Corner
Category: All Articles
Simple things on the web are rarely simple. For example, take rounded corners. Ever wonder why the web is so square? Like the ASCII screens of the past, HTML/CSS just doesn't provide a simple way to do anything other than squared corners. Adding rounded corners takes us to an entirely different realm, where simplicity is out the window and complexity forces us to our knees at the alter of Hacks In Support of Design Ideals. I'll identify two typical methods for doing so, and then illustrate how CSS 3 saves us ton of heartache — until you consider Microsoft Internet Exploder. Take, for example, the typical box on a page:
That's pretty straight-forward code. Now, let's look at two common methods for adding rounded corners to the mix (yes, grasshopper, there are many more methods than I'm willing to show here — but they're all similarly convoluted). The Seventh Circle of ScriptThe first method is to use javascript to parse the DOM looking for specific elements, which are then changed dynamically. For browsers without javascript enabled, the standard square corners will be displayed.
Cult of the Nested DIVThe next method is just as hairy and inaccessible to the casual HTML coder. It involves Photoshopping the four individual rounded corners, then using them as backgrounds of nested DIVs. Oy!
Salvation is IterativeThe soon-to-be-standardized CSS 3 provides a simple mechanism for creating rounded corners on a wide variety of elements. It will even round the corners of images! While CSS 3 is not yet ratified, both Mozilla (AKA Firefox) and WebKit (AKA Safari and Chrome) have responded to the huddled masses of developers desperate for relief. What they've done is added support for several great CSS 3 features in their most recent browsers (Firefox 3.5, Safari 4 and Google Chrome). Here is the exceptionally simple CSS 3 method for creating a DIV with rounded corners:
Nifty, eh? Even better is that you can set the border radius on all four corners independent of each other, in order to create some interesting shapes. This method degrades on non-CSS3 browsers to show a square box without rounded corners. But Not UniversalMicrosoft's recently released Internet Explorer 8 doesn't support *any* CSS 3 proposed standards. Grrr. Great ExampleA complex example of CSS 3 Border Radius: http://forestmist.org/wp-content/uploads/2009/10/bahamas-logo-using-css3.html |
Articles by Category
This Article's Tags
Related Articles
|
|||||||||||||||||||||||||||||||||



