Home >Web Front-end >CSS Tutorial >How to set rounded borders in css? How to set rounded borders in css (image and text)

How to set rounded borders in css? How to set rounded borders in css (image and text)

不言
不言Original
2018-09-08 14:00:3631245browse

How to set the border in css? Many times when developing the front-end of a web page, in order to make the things on the web page look more comfortable, we may need to set some rounded borders such as buttons. So, how do we set rounded borders? This article will introduce to you how to set rounded borders in CSS.

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

CSS rounded corners only need to set one property: border-radius (meaning "border radius"). You provide a value for this property to set the radii of all four corners at the same time. All legal CSS measurements can be used: em, ex, pt, px, percentage, etc.

Let’s take a look at a css code example to set a rounded border:

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
text-align:center;
border:2px solid #a1a1a1;
padding:80px 40px; 
background:pink;
width:150px;
border-radius:25px;
-moz-border-radius:25px; /* 老的 Firefox */
}
</style>
</head>
<body>
<div>圆角边框</div>
</body>
</html>

The effect is as follows:

How to set rounded borders in css? How to set rounded borders in css (image and text)

border-radius can be set to 1 at the same time to 4 values.

If you set a value, it means that all four fillets use this value.

css rounded border code: border-radius: 15px;

How to set rounded borders in css? How to set rounded borders in css (image and text)

##If two values ​​are set , indicating that the upper left corner and lower right corner use the first value, the upper right and lower left corners use the second value.

css rounded border code: border-radius: 15px 5px;

How to set rounded borders in css? How to set rounded borders in css (image and text)

If three values ​​are set, it means that the first value is used in the upper left corner, and the upper right corner is The second value is used for the corner and lower left corner, and the third value is used for the lower right corner.

css rounded border code: border-radius: 15px 5px 25px;

How to set rounded borders in css? How to set rounded borders in css (image and text)

If set four values, then in order Corresponds to the upper left corner, upper right corner, lower right corner, and lower left corner (clockwise order).

css rounded border code: border-radius: 15px 5px 25px 0px;

How to set rounded borders in css? How to set rounded borders in css (image and text)

border-radius can also use slashes to set the second set of values. The first set of values ​​represents the horizontal radius, and the second set of values ​​represents the vertical radius. The second set of values ​​can also set 1 to 4 values ​​at the same time, and the application rules are the same as the first set of values.

In addition to setting four rounded corners at the same time, you can also set each corner individually. Corresponding to the four corners, CSS3 provides four separate properties:

border-top-left-radius

border-top-right-radius
border-bottom-right-radius
border -bottom-left-radius

These four properties can be set to 1 to 2 values ​​​​at the same time. If you set a value of 1, it means that the horizontal radius is equal to the vertical radius. If 2 values ​​are set, the first value represents the horizontal radius and the second value represents the vertical radius.

The above is how to set rounded borders in css. If you want to know more about css border properties, you can refer to

css manual.

The above is the detailed content of How to set rounded borders in css? How to set rounded borders in css (image and text). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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

Related articles

See more