Web Design Blog

This is where we store some of our Web Development thoughts, tips and tricks, just because we like to share.

Rounded Corners With CSS

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.

15 Oct 2008 / 2 Comments / CSS Tips & Tricks / by Maruf

2 Comments

  1. Deano
    19/10/2008
    1

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

  2. Pete
    30/10/2008
    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.

Leave a Reply

© 2012 BrightCherry :)