How to set border rounded corners in css

青灯夜游
Release: 2021-10-12 14:57:59
original
25625 people have browsed it

In CSS, you can use the border-radius attribute to set the border rounded corners. The function of this attribute is to add a rounded corner effect to the border. You only need to add "border-radius: rounded corner radius value;" to the element. Style, you can set the rounded corners of four borders at the same time.

How to set border rounded corners in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

The most common and simplest way to set border rounded corners in css is to use the border-radius attribute.

CSS border-radius property defines the radius of the corner of the element. Through the CSS border-radius property, the "rounded corner" style of any element can be achieved.

Syntax:

border-radius: none | length{1,4} [/ length{1,4}
Copy after login

Each value can be in the form of a numerical value or a percentage.

length/length The first length represents the radius in the horizontal direction, and the second represents the radius in the vertical direction.

If it is a value, then the four values ​​​​of top-left, top-right, bottom-right, and bottom-left are equal.

If there are two values, then top-left and bottom-right are equal and are the first value, and top-right and bottom-left are equal and are the second value.
How to set border rounded corners in css
If there are three values, then the first value is to set top-left, and the second value is top-right and bottom-left and they will be equal, and the third value is to set bottom-right.
How to set border rounded corners in css
If there are four values, then the first value is to set top-left, and the second value is to set top-right, the third value is to set bottom-right, and the fourth value is to set bottom- left
How to set border rounded corners in css

In addition to the above abbreviations, you can also write the four corners separately like border, as follows:

border-top-left-radius: //左上角 
border-top-right-radius: //右上角 
border-bottom-right-radius: //右下角 
border-bottom-left-radius: //左下角
Copy after login

are the horizontal directions respectively and the vertical radius. When the second value is omitted, the horizontal and vertical radii are equal.
border-radius only supports the border-radius standard syntax format in the following versions of browsers: Firefox4.0, Safari5.0, Google Chrome 10.0, Opera 10.5, and IE9. For older browsers, border-radius needs to be based on Different browser kernels add different prefixes. For example, the Mozilla kernel needs to add "-moz", and the Webkit kernel needs to add "-webkit", etc. However, IE and Opera do not have private formats, so in order to maximize browser compatibility , we need to set it as follows:

-webkit-border-radius: 10px 20px 30px; 
-moz-border-radius: 10px 20px 30px; 
border-radius: 10px 20px 30px;
Copy after login

Please write the standard form after the browser private form.

Give a few examples to see the effect:











How to set border rounded corners in css
Copy after login

Effect:

How to set border rounded corners in css
The radius of the four corners is 30px;

Look at a standard circle and ellipse again:











Copy after login

Effect:
How to set border rounded corners in css
The difference between the first and second p mainly lies in whether it is a square or a rectangle. The circle is in When carouseling, it can be used instead of the circle picture.

The above are examples of equal radii in the horizontal and vertical directions. Here are two examples of different radii in the horizontal and vertical directions:











Copy after login

The effect is as follows:

How to set border rounded corners in css

(Learning video sharing: css video tutorial)

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

Related labels:
css
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 [email protected]
Latest issues
Popular Tutorials
More>
Latest downloads
More>
web effects
Website source code
Website materials
Front end template
About us Disclaimer Sitemap
PHP Chinese website:Public welfare online PHP training,Help PHP learners grow quickly!