Code Snippets Gallery
Rounded Corners
Standard:
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */Individual Corners:
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 20px;
-moz-border-radius-bottomright: 30px;
-moz-border-radius-bottomleft: 0;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 20px;
-webkit-border-bottom-right-radius: 30px;
-webkit-border-bottom-left-radius: 0;Shorthand:
-moz-border-radius: [top-left] [top-right] [bottom-right] [bottom-left]
-moz-border-radius: 10px 20px 30px 0;Elliptical Rounding (Firefox 3.5+):
-moz-border-radius-topleft: [horizontal radius] [vertical radius];
-moz-border-radius-topleft: 10px 40px;Elliptical Rounding Shorthand (Firefox 3.5+):
-moz-border-radius: [horizontal radius] / [vertical radius];
-moz-border-radius: 10px / 40px;-moz-border-radius: 10px 20px 30px 40px / 15px 30px 45px 60px;Above is the same as:
-moz-border-radius-topleft: 10px 15px;
-moz-border-radius-topright: 20px 30px;
-moz-border-radius-bottomright: 30px 45px;
-moz-border-radius-bottomleft: 40px 60px;WebKit Elliptical Rounding
All corners:
-webkit-border-radius: 36px 12px;Right corners only:
-webkit-border-top-right-radius: 50px 30px;
-webkit-border-bottom-right-radius: 50px 30px;
Thank you for including my additions. Some more additions:
Elliptical rounding:
-webkit-border-top-left-radius: 10px 40px;Elliptical rounding shorthand:
(notice: no slash)
-webkit-border-radius: 10px 40px;this is not compatible for IE browsers. Can u help me fix
I did not still get answers to my question. This code is not compatible for IE browers
All versions to date of IE don’t support any CSS3 so you will either have to just employ progressive enhancement (i.e. decent browsers get rounded corners IE does not) or use images and or javascript to round your corners.
@Prydie
Opera doesn’t support border-radius yet either.
You can make it work by including CurvyCorners:
Then border-radius will also work in Opera and IE 4.0(!) and newer.
so what is more preferred this or the image style
This (with or without CurvyCorners depending on the browsers you want to support).
Creating images for round corners is more work, more http requests and more bandwidth then using border-radius.
I really hate the rounded corner issue in IE and other browsers with a lack of descent CSS support.
Is there a nice and clean method that will work in all the browsers? Preferably a jQuery plugin?
Only problem is that the CSS will not validate at the W3C CSS Validation Service.
I think we’re beyond anybody really caring about validation as the CSS 2.1 spec has not even been properly supported. Ignore validation until then point where there is a definitive spec to actually validate against!
great and simple!
Is it true, that Firefox ignores rounded corners on images?
Can’t seem to get it to work.
Yes, firefox has no support for rounded corners on images, yet.
That said its very east to do in photoshop.
Safari requires more than shorthand if you want differing corner radii. You have to write out each unique corner.
To get rounded corners to work in IE 6-8 you need an htc file as a work around try this:
http://code.google.com/p/curved-corner/
Just download the file and follow the directions and you can integrate it with your current css solutions.
It can be a little wonky so follow ALL the suggestions and dl the zip file with an example in it if you need to.
A great way to generate rounded corners is border-radius.com.
It’s simple to use and generates the css for webkit and gecko proprietary extensions as well as the css3 version.
You can also set the value of each corner and it’ll spit that code out as well.
You can have a look as well at FlexiPanels CSS – a Dreamweaver extension that creates rounded corner CSS boxes without coding.
Hey, Opera 10.5+ and Internet Explorer 9.0+ fully supports border-radius!
a noob question, with code like this just where in the css should a person put this type of code o make it work, in the body definition or elsewhere?