CSS Border Radius Percentages and Elliptical Borders
When using CSS border radius I’ve always specified the radius in pixels (px), something like this:
.round-box {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
This got me to wondering, does it support percentages as well? So I tried this:
.round-box {
border-radius: 5%;
-moz-border-radius: 5%;
-webkit-border-radius: 5%;
}
This worked in Firefox 3.6 but not in Chrome. Some searching around revealed the Mozilla -moz-border-radius page. For border radius it specifically mentions that it supports length units as well as percentages:
A percentage, relative to the width of the box (the percentage is relative to the width even when specifying the radius for a height).
That page also mentioned support for elliptical borders. To do that you add another radius value separated by a slash:
.round-box {
border-radius: 15px / 50px;
-moz-border-radius: 15px / 50px;
-webkit-border-radius: 15px / 50px;
}
The elliptical border worked on Chrome as well. If you bend this tight enough you can get pretty close to a circle.
I wanted Internet Explorer to add support for border radius before; now that I’ve got even more radius toys to play with I’m practically begging. I’m sorry Internet Explorer users but I’m tired of various border hacks when there are simple and clean CSS methods available.
Related posts:
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No imgs?
The only thing that’s really different is the elliptical borders, which you can see on the Mozilla docs page – https://developer.mozilla.org/en/CSS:-moz-border-radius#Live_Examples