Easy Rounded Corners using CSS3 This article takes a look at the css3 border-radius property which allows developers to easily create rounded corners in their web pages. Prior to css3, developers needed to use approaches such as using corner images to give an illusion of rounded corners or arranging multiple div tags to give a smooth rounded look. Syntax Setting rounded corners using css3 is easier than 1-2-3. Just set the "border-radius" property and take a look at the results. As with any other "new" properties/features, you do need to ensure client browser support. #roundcnr1 { border-radius: 12px; } In previous firefox versions, you needed to specify the -moz- prefix for Firefox browsers ( -moz-border-radius: ...). The current/newer versions of firefox work without needing the -moz- prefix. Sample in action Source Code
<!DOCTYPE html><head><style>#roundcnr1 { -moz-border-radius: 12px; border-radius: 12px;border-style: solid; border-color: #996600; border-width: 1px; } </style></head><body>Div without Rounded corners<BR/><br/><div style="border: 1px solid black;width:100px;" >Hello - without rounded borders </div><BR/>Div with Rounded corners<br/><BR/><div style="border: 1px solid black;border-radius:10px;width:100px;" >Hello - with rounded borders </div><BR/>Table without Rounded corners<br/><BR/><table style="border: 1px solid black;"><tr><td>Row1 Col1 </td><td>Row1 Col2 </td></tr><tr><td>Row2 Col1 </td><td>Row2 Col2 </td></tr></table><BR/>Table with Rounded corners<br/><BR/><table style="border: 1px solid black;border-radius:4px"><tr><td>Row1 Col1 </td><td>Row1 Col2 </td></tr><tr><td>Row2 Col1 </td><td>Row2 Col2 </td></tr></table><br/></body>
Table2 with Rounded corners<br/><BR/><table style="border: 1px solid black;border-radius: 2px 5px 3px 1px / 7px 4px 17px 6px;"><tr><td>Row1 Col1 </td><td>Row1 Col2 </td></tr><tr><td>Row2 Col1 </td><td>Row2 Col2 </td></tr></table>
Units: The units can be specified as length (px) or percentage can be used. Conclusion In this article we saw how easy it is to render custom rounded corners using a single css3 property. We took a look at the power and flexibility pf the border-radius. Happy Coding!
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: