WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

CSS3 Rounded Corners


CSS3 Rounded Corners

With the CSS3 border-radius property, you can give any element "rounded corners".


Browser Support

The numbers in the table indicate the first browser version number that supports this attribute.

The number immediately before -webkit-, -ms- or -moz- is the first browser version number that supports this prefix attribute.

Property
border-radius 5.0
4.0 - webkit-
12.0 9.0 4.0
3.0 - moz-
5.0
3.1 - webkit-
10.5

CSS3 border range Property

With CSS3, you can give any element "rounded corners", by utilizing the border-radius property.

Here are three examples:

1. Adjusted corners for a element with a predefined background color:

Rounded corners!

2. Adjusted corners for a element with a border:

Rounded corners!

3. Adjusted corners for a element with a background image:

Rounded corners!

Here is the code:

Example

#rcorners1 { border-radius: 25px;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    } #rcorners2 { border-radius: 25px;
    border: 2px solid hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    } #rcorners3 { border-radius: 25px;
    background: url(paper.gif);
    background-position: left top;
    background-repeat: repeat;
    padding: 20px;
    width: 200px;
    height: 150px;
    }
Try it yourself »

CSS3 border radius - Specify Each Corner

If you indicate just a single an incentive for the border-radius property, this radius will be connected to each of the 4 corners.

However, you can determine each corner independently in the event that you wish. Here are the rules:

  • Four values: first esteem applies to upper left, second esteem applies to upper right, third esteem applies to base right, and fourth esteem applies to base left corner
  • Three values: first esteem applies to upper left, second esteem applies to upper right and base left, what's more, third esteem applies to base right
  • Two values: first esteem applies to upper left and base right corner, and the second esteem applies to upper right and base left corner
  • One value: every one of the four corners are adjusted equally

Here is the code:

Example

#rcorners4 { border-radius: 15px 50px 30px 5px;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    } #rcorners5 { border-radius: 15px 50px 30px;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    } #rcorners6 { border-radius: 15px 50px;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    }
Try it yourself »

You could likewise make curved corners:

Example

#rcorners7 { border-radius: 50px/15px;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    } #rcorners8 { border-radius: 15px/50px;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    } #rcorners9 { border-radius: 50%;
    background: hotpink;
    padding: 20px;
    width: 200px;
    height: 150px;
    }
Try it yourself »