Rounded Corners With CSS

Image frame
Rounded Corners With CSS
Maruf
Oct 15th, 2008
Maruf scribbled this post.

This is a pretty simple but useful tutorial. A lot of people physically create round-edged backgrounds with applications like Photoshop. While this is time-consuming and a complete nightmare for updating purposes, there is a much more efficient way of doing this with the use of CSS. Only problem is that it doesn’t work in all browsers just yet e.g Internet Explorer :( However, it works with the cool, geeky browsers like Firefox. If anyone knows an I.E fix, holla!

For example, if you want this image to have rounded edges:

To do the following:

You can use the following CSS code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 #nonround{
height:200px;
width:200px;
background:red;
margin-top:20px;
}
 
#round{
height:200px;
width:200px;
background:red;
margin-top:20px;
 -webkit-border-top-left-radius:10px;
 -webkit-border-top-right-radius:10px;
 -webkit-border-bottom-left-radius:10px;
 -webkit-border-bottom-right-radius:10px;
 
 -khtml-border-radius-topleft:10px;
 -khtml-border-radius-topright:10px;
 -khtml-border-radius-bottomleft:10px;
 -khtml-border-radius-bottomright:10px;
 
 -moz-border-radius-topleft:10px;
 -moz-border-radius-topright:10px;
 -moz-border-radius-bottomleft:10px;
 -moz-border-radius-bottomright:10px;	
}

(the various rules are somewhat duplicated so they work across various browsers)

Cool, right? Right.


Filed away: CSS

comments

Image frame
1

Very cool mate. Lets hope it works in IE soon.

Deano
Oct 19th, 2008
Image frame
2

Yep, it’s a great technique that I too have been employing.

IE will have to wait, think I may make an appearance in IE8 though.

Personally I think if it’s used to give ‘extra coolness’ to elements like buttons it’s totally fine that IE doesn’t support it as it will just render square, which is perfectly fine.

Pete
Oct 30th, 2008

feel free to leave a scribble

Name:
Email:
gravatar
Want an image next to your comments?
visit gravatar.com
Message:
Get a free quote