- photo contests ▼
- photoshop contests ▼
- Tutorials ▼
- Social ▼Contact options
- Stats ▼Results and stats
- More ▼
- Help ▼Help and rules
- Login
/* 5 px rounded corners on all sides */
-moz-border-radius:5px;
-webkit-border-radius:5px;
/* 5 px rounded corners on only the top sides (top left and top right) */
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
If you’re going to go all the way with CSS3, combining rounded corners with border images and border styles will allow you to accomplish very complex effects. However, most designers will have to provide full cross-browser compatibility.
Howdie stranger!
If you want to participate in our photoshop and photography contests, just:
LOGIN HERE or REGISTER FOR FREE
Nice roundup. I would just add that when using the webkit and moz border radius properties, you should follow it up with the standard CSS3 “border-radius” to future proof it.
You can also combine a JS and image solution, adding the divs necessary to cover each corner with a rounded effect after the page is loaded (progressive enhancement), thus keeping design and content separate.
( 2 years and 4677 days ago )Nice roundup and tips. For one of my sites, I think I’ll have to try a combination of CSS3 and javascript. Thanks Ivan.
( 2 years and 4677 days ago )It seems that the 3rd solution to be most common if you want to be compatible to all browsers, but I believe that the css3 power will be adopted soon by all browsers, and we could get rid of all this hacks
( 2 years and 4677 days ago )I appreciate that you are posting information for those who are just learning all this. But it must be said that this information has been rehashed MANY times on many web design blogs over the past year or so with the renewed interest in CSS3.
So while I give you a “back pat” for your efforts to summarize the available methods in one concise post and give the less-initiated a easy to digest introduction to the techniques for rounded corners, I have to at the same time point out an omission on your part which is rather surprising (disappointing) given how many web design blog authors have already written on the subject.
In the CSS3 example, you left out the actual CSS3 border-radius property. The ‘-moz-” and “-webkit-” prefixes are in fact not valid CSS3, but are proprietary vendor-specific extensions; they work for their respective browsers only.
Best practice is to also include the actual CSS3 property (border-radius) so that you have forward-compatibility for browsers that implement the actual spec. Just like the vendor extensions, browsers that don’t understand the CSS3 property will simply ignore it. The result is a more robust cross-browser solution that degrades gracefully while anticipating future standards support. That is the key concept to all CSS3 progressive enhancement techniques, actually.
I hope you go back to correct your post so your less-informed readers learn the best practice approach here. Rant over. 😉
( 2 years and 4677 days ago )“Graceful Degradation” dictates which method is best to use, for me, by far, CSS3 border-radius is the way to go.
Yes, none IE version supports it, so what, users’ experience won’t be affected by that, having rounded corners or not is not something users’ demand or look for (unless you’re a Web Designer), that’s why I mention Graceful Degradation.
Just keep in mind that in the future, IE WILL support border-radius, so you write the CSS3 standard declaration and then proprietary ones, ie:
div.container {
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
}
Nice post, but where’s “border-radius”? It’s really important now for recent browsers that are not Firefox or based on WebKit.
( 2 years and 4676 days ago )[…] 4 Ways to Get Rounded Corners Using CSS – Pxleyes.com Blog "Rounded corners are a common CSS effect these days. There are several ways to accomplish this effect, and how you go about implementing rounded corners will depend largely on what purpose they will serve in your design. Keep this in mind, because it can save you hours of unnecessary work. In certain cases, rounded corners can be accomplished very easily, and in others they may be the single most challenging part of the design. This article will attempt to point you directly to the solution you need." (tags: webdesign) […]
( 2 years and 4676 days ago )[…] 4 Ways to Get Rounded Corners Using CSS Via / Script & Style […]
( 2 years and 4676 days ago )You can have a look at FlexiPanels CSS as well – it’s a Dreamweaver extension that makes rounded corners CSS boxes starting from a picture without writing code.
( 2 years and 4676 days ago )Intresting post. Thanks
( 2 years and 4676 days ago )Safari (as of 4.0.4) does not support the following syntax:
-webkit-border-radius: 5px 5px 0 0; /* chrome only */
It requires:
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
Another thought on CSS3 Corners on IE from designinformer.com:
“To be frank, nothing in your layout is going to break if IE displays straight corners. The chances of a viewer poking their eye out on one of your sharp corners is very slim, so stop worrying about it. If you really want IE support, be my guest. You’ll need to use images, complicated CSS and extra markup.”
– http://designinformer.com/use-css3-now/
hihihihi 😀
https://developer.mozilla.org/en/CSS/-moz-border-radius
A fifth method (possibly a variation of the fourth method) is to use CSS background repetition/positioning instead of using absolute positioning/negative margins. Its discussed here:
Box with Round Corners Using CSS and Images – Part 2
( 2 years and 4662 days ago )If you’re not looking exclusively for a CSS3 or non JS/image solution, then you could have a look at Flexi Panels CSS – the Dreamweaver extension that makes rounded corner CSS without coding.
( 2 years and 4404 days ago )Nice one 🙂
( 2 years and 4270 days ago )nice one
( 2 years and 4270 days ago )
Thanks for this article.
I am using only the -moz-border-radius / -webkit-border-radius — with bottomright etc. what I want.
( 2 years and 4677 days ago )