Home > Web Front-end > Front-end Q&A > How to set rounded corners in css3

How to set rounded corners in css3

藏色散人
Release: 2023-01-04 09:36:07
Original
3206 people have browsed it

In CSS3, you can use the "border-radius" attribute to set rounded corners for any element. The complete code for setting rounded corners is such as "border-radius:25px;padding:20px;width:200px;height: 150px;".

How to set rounded corners in css3

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

CSS3 border-radius property

Using the CSS3 border-radius property, you can make "rounded corners" for any element.

The following are three examples:

1. Specify the background color of the element with rounded corners:

How to set rounded corners in css3

2. Specify the border of the element with rounded corners Corner:

How to set rounded corners in css3

3. Specify the rounded corner of the element of the background image:

How to set rounded corners in css3

The code is as follows:

Example

#rcorners1 {
    border-radius: 25px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}
#rcorners2 {
    border-radius: 25px;
    border: 2px solid #8AC007;
    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;
}
Copy after login

CSS3 border-radius - Specify each rounded corner

If you specify only one value in the border-radius property, 4 rounded corners will be generated.

However, if you want to specify the four corners one by one, you can use the following rules:

  • Four values: The first value is the upper left corner, the The second value is the upper right corner, the third value is the lower right corner, and the fourth value is the lower left corner.

  • Three values: the first value is the upper left corner, the second value is the upper right corner and the lower left corner, and the third value is the lower right corner

  • Two values: the first value is the upper left corner and the lower right corner, the second value is the upper right corner and the lower left corner

  • One value: the four rounded corners have the same value

[Recommended learning: "css video tutorial"]

The above is the detailed content of How to set rounded corners in css3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template