border-radius四个值顺序(border-radius属性用法解析)

 分类:css3知识时间:2022-06-08 07:30:23点击:

在css3中border-radius是用来给任何元素制作 "圆角"。 border-radius属性统一指定4个圆角,其四个值顺序为左上、右上、右下和左下。其实css3中的border-radius属性实际是border-top-left-radius, border-top-right-radius, border-bottom-right-radius 和 border-bottom-left-radius 属性的简写。

一、border-radius四个值顺序

1、顺序为左上、右上、右下和左下

2、可以根据自己开发的需求,分别指定每个角。以下是规则:

四个值: 第一个值适用于左上角,第二个值适用于右上方,第三值应用于右下角,第四值适用于左下角。

三个值: 第一个值适用于左上,二值适用于右上和左下,右下第三值适用于。

两个值: 第一个值适用于左上和右下角,和二值适用于右上和左下角。

一个值: 所有的四个角都是圆的。

二、border-radius属性用法

1、最基本的使用方法,实例代码如下:

.round {
border-radius: 5px; /* 所有角都使用半径为5px的圆角,此属性为CSS3标准属性 */
-moz-border-radius: 5px; /* Mozilla浏览器的私有属性 */
-webkit-border-radius: 5px; /* Webkit浏览器的私有属性 */
border-radius: 5px 4px 3px 2px; /* 四个半径值分别是左上角、右上角、右下角和左下角 */
}

2、用border-radius画实心圆

是用border-radius属性画出来的一个完美的实心圆。画实心圆的方法是高度和宽度相等,并且把border的宽度设为高度和宽度的一半。

实例代码如下:

#circle{
width: 200px;
height: 200px;
background-color: #efefef; 
border: 3px solid #a72525;
-webkit-border-radius: 100px;
}

border-radius四个值顺序

3、用border-radius画虚线圆

实例代码如下:

#circle{
width: 200px;
height: 200px;
background-color: #efefef; 
border: 3px dashed #a72525;
-webkit-border-radius: 100px 100px 100px 100px;
}

border-radius四个值顺序

4、用border-radius画半圆

以本例来讲,半圆的画法是把宽度设为高度的一半,并且也只设置左上角和左下角的半径。

实例代码如下:

#quartercircle {
width: 200px;
height: 100px;
background-color:  #a72525;
-webkit-border-radius:  200px 0 0 200px;
}

border-radius四个值顺序

5、用border-radius画四分之一圆

四分之一圆的实现方法是把高度和宽度设置为相等,只设置一个圆角,其半径等于高度或宽度。

实例代码如下:

#quartercircle {
width: 200px;
height: 200px;
background-color: #a72525;
-webkit-border-radius: 200px 0 0 0;
}

border-radius四个值顺序

除注明外的文章,均为来源:老汤博客,转载请保留本文地址!
原文地址: