Create Rounded Corners Using CSS – for Firefox & Safari

Advertisement

W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function, which allows you to create round corners on box-items. Most of the people doesn’t know about this CSS feature and so I am sharing it here for you.

The two length values of the ‘border-radius’ properties define the radii of a quarter ellipse that defines the shape of the corner (see the diagram below). The first value is the horizontal radius (or vertical if the ‘writing-mode’ is vertical). If the second length is omitted it is equal to the first (and the corner is thus a quarter circle). If either length is zero, the corner is square, not rounded. The border radius also causes the element’s background to be rounded, even if the border is ‘none’. Negative values are not allowed.

Mozilla/Firefox and Safari 3 users should see a nicely rounded box, with a nicely rounded border.

The code for this example above is actually quite simple. Have a look at it given below.

<div style=”border: 1px solid #666666; padding: 20px; -moz-border-radius-topleft: 10px; -moz-border-radius-topright: 10px; -moz-border-radius-bottomright: 10px; -moz-border-radius-bottomleft: 10px; background-color: #f3f3f3;”>

All the four different corners can also be handled by their own, Mozilla has other names for the feature than the W3C specifications says, like -moz-border-radius-topright as opposed to -webkit-border-top-right-radius

-moz-border-radius-topleft OR -webkit-border-top-left-radius
-moz-border-radius-topright OR -webkit-border-top-right-radius
-moz-border-radius-bottomleft OR -webkit-border-bottom-left-radius
-moz-border-radius-bottomright OR -webkit-border-bottom-right-radius
Mozilla/Firefox and Safari 3 users should see a box with a rounded left upper corner.
Mozilla/Firefox and Safari 3 users should see a box with a rounded right upper corner.
Mozilla/Firefox and Safari 3 users should see a box with a rounded left lower corner.
Mozilla/Firefox and Safari 3 users should see a box with a rounded right lower corner.

Unfortunately it seems that this CSS feature doesn’t works with IE 6 & 7. Hope this works with the new version of IE.

Hope you enjoyed this post. What do you think about this method of creating rounded corners? If you have any better ideas about creating a drop shadow suing CSS please let us know. Comments, feed backs and critics are most welcome.

Share the Awesomness

  • social icons
  • social icons
  • social icons
  • social icons
  • social icons
  • social icons
  • social icons
  • social icons

No comments yet.

Leave a Comment