CSS中的border-radius属性

CSS | 边界半径属性 (CSS | border-radius Property)

The border-radius property is commonly used to convert box elements into circles. We can convert box elements into the circle element by setting the border-radius to half of the length of a square element.

border-radius属性通常用于将框元素转换为圆形。 通过将边框半径设置为正方形元素长度的一半,我们可以将框元素转换为圆形元素。

Syntax:

句法:

Element {
    Width: 150px;
    Height: 150px;
    border-radius: 50%;
}

Example:

例:

<!DOCTYPE html>
<html>

<head>
    <style>
        p {
            background: #73AD21;
            width: 200px;
            height: 150px;
            border-radius: 50%
        }
    </style>
</head>

<body>
    <h1>CSS Rounded Corners</h1>
    <p></p>
</body>

</html>

Output

输出量

Border Radius Property in CSS | Example 1

In the above example, 50% border-radius is applied to all the corners.

在上面的示例中,将50%的边界半径应用于所有角。

1)具有一个值的border-radius属性 (1) border-radius property with one value)

The property takes a single value to the border-radius and that value is applied to all the four corners and the corners are rounded equally.

该属性对边界半径采用单个值,并且该值应用于所有四个角,并且这些角均等地舍入。

Syntax:

句法:

Element {
    border-radius: 15px;
}

Example:

例:

<!DOCTYPE html>

<html>

<head>
    <style>
        div {
            border: 2px solid red;
            padding: 10px;
            border-radius: 25px;
        }
    </style>
</head>

<body>
    <div>
        <p>Border Radius in CSS</p>
    </div>
</body>

</html>

Output

输出量

Border Radius Property in CSS | Example 2

In the above example, the border-radius of 25px is applied to all four sides equally.

在上面的示例中, 边界半径 25px均等地应用于所有四个侧面。

2)具有两个值的border-radius属性 (2) border-radius property with two values)

This property takes two values to the border-radius. The first value is applied to top-left and bottom-right corners, the second value is applied to top-right and bottom-left corners.

此属性将border-radius取两个值。 第一个值应用于左上角和右下角 ,第二个值应用于右上角和左下角 。

Syntax:

句法:

Element {
    border-radius: 15px 10px;
}

Example:

例:

<!DOCTYPE html>

<html>

<head>
    <style>
        div {
            border: 2px solid red;
            padding: 10px;
            border-radius: 60px 30px;
        }
    </style>
</head>

<body>
    <div>
        <p>Border Radius in CSS</p>
    </div>
</body>

</html>

Output

输出量

Border Radius Property in CSS | Example 3

In the above example, the border-radius of 60px is applied to top-left and bottom-right and 30px is applied to top-right and bottom-left corners.

在上面的示例中, 边框半径 60px应用于左上角和右下角,而30px应用于右上角和左下角 。

3)具有三个值的border-radius属性 (3) border-radius property with three values)

This property takes three values to the border-radius. The first value is applied to the top-left corner and the second value is applied to top-right and bottom-left corners, and the third value is applied to the bottom-right corner.

该属性将border-radius取三个值。 所述第一值被施加到左上角和所述第二值被施加到右上和左下的角,并且所述第三值被施加到右下角 。

Syntax:

句法:

Element {
    border-radius: 15px 10px 30px;
}

Example:

例:

<!DOCTYPE html>

<html>

<head>
    <style>
        div {
            border: 2px solid green;
            padding: 10px;
            border-radius: 60px 30px 20px;
        }
    </style>
</head>

<body>
    <div>
        <p>Border Radius in CSS</p>
    </div>
</body>

</html>

Output

输出量

Border Radius Property in CSS | Example 4

In the above example, border-radius of 60px is applied to top-left corner, 30px is applied to top-right and bottom-left corners and 20px is applied to bottom-right corner.

在上面的例子中,60像素 边界半径被施加到左上角 ,30像素被施加到右上和左下的角和20像素被施加到右下角 。

4)具有四个值的border-radius属性 (4) border-radius property with four values)

This property takes four values to the border-radius and applies four different values to each of the corners. The first value is applied to the top-left corner, the second value is applied to the top-right corner, the third value is applied to the bottom-right corner and the fourth value is applied to the bottom-left corner.

此属性将四个值应用于边界半径 ,并将四个不同的值应用于每个角。 所述第一值被施加到左上角 ,第二值被施加到右上角 ,第三值被施加到右下角和第四值被施加到左下角 。

Syntax:

句法:

Element {
    border-radius: 15px 10px 20px 5px;
}

Example:

例:

<!DOCTYPE html>

<html>

<head>
    <style>
        div {
            border: 2px solid green;
            padding: 10px;
            border-radius: 60px 30px 50px 10px;
        }
    </style>
</head>

<body>
    <div>
        <p>Border Radius in CSS</p>
    </div>
</body>

</html>

Output

输出量

Border Radius Property in CSS | Example 5

In the above example, 60px is applied to top-left corner, 30px is applied to the top-right corner, 50px is applied to bottom-right corner and 10px is applied to bottom-left corner of the box.

在上述例子中,60像素被施加到左上角 ,30像素被施加到右上角 ,50像素被施加到右下角和10px的被施加到盒的左下角 。

翻译自: https://www.includehelp.com/code-snippets/the-border-radius-property-in-css.aspx

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值