border-radius
CSS
property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.
The radius applies to the whole
background
, even if the element has no border; the exact position of the clipping is defined by the
background-clip
特性。
border-radius
property does not apply to table elements when
border-collapse
is
collapse
.
border-radius:0 0 inherit inherit
, which would partially override existing definitions. Instead, the individual longhand properties have to be used.
此特性是下列 CSS 特性的简写:
/* The syntax of the first radius allows one to four values */ /* Radius is set for all 4 sides */ border-radius: 10px; /* top-left-and-bottom-right | top-right-and-bottom-left */ border-radius: 10px 5%; /* top-left | top-right-and-bottom-left | bottom-right */ border-radius: 2px 4px 2px; /* top-left | top-right | bottom-right | bottom-left */ border-radius: 1px 0 3px 4px; /* The syntax of the second radius allows one to four values */ /* (first radius values) / radius */ border-radius: 10px / 20px; /* (first radius values) / top-left-and-bottom-right | top-right-and-bottom-left */ border-radius: 10px 5% / 20px 30px; /* (first radius values) / top-left | top-right-and-bottom-left | bottom-right */ border-radius: 10px 5px 2em / 20px 25px 30%; /* (first radius values) / top-left | top-right | bottom-right | bottom-left */ border-radius: 10px 5% / 20px 25em 30px 35em; /* Global values */ border-radius: inherit; border-radius: initial; border-radius: unset;
border-radius
property is specified as:
<length>
or
<percentage>
values. This is used to set a single radius for the corners.
<length>
or
<percentage>
values. This is used to set an additional radius, so you can have elliptical corners.
| radius |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in each corner of the border. It is used only in the one-value syntax.
|
| top-left-and-bottom-right |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in the top-left and bottom-right corners of the element's box. It is used only in the two-value syntax.
|
| top-right-and-bottom-left |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in the top-right and bottom-left corners of the element's box. It is used only in the two- and three-value syntaxes.
|
| top-left |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in the top-left corner of the element's box. It is used only in the three- and four-value syntaxes.
|
| top-right |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in the top-right corner of the element's box. It is used only in the four-value syntax.
|
| bottom-right |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in the bottom-right corner of the element's box. It is used only in the three- and four-value syntaxes.
|
| bottom-left |
|
是
<length>
或
<percentage>
denoting a radius to use for the border in the bottom-left corner of the element's box. It is used only in the four-value syntax.
|
<length>
Denotes the size of the circle radius, or the semi-major and semi-minor axes of the ellipse, using length values. Negative values are invalid.
<percentage>
Denotes the size of the circle radius, or the semi-major and semi-minor axes of the ellipse, using percentage values. Percentages for the horizontal axis refer to the width of the box; percentages for the vertical axis refer to the height of the box. Negative values are invalid.
例如:
border-radius: 1em/5em; /* ... is equivalent to: */ border-top-left-radius: 1em 5em; border-top-right-radius: 1em 5em; border-bottom-right-radius: 1em 5em; border-bottom-left-radius: 1em 5em;
border-radius: 4px 3px 6px / 2px 4px; /* ... is equivalent to: */ border-top-left-radius: 4px 2px; border-top-right-radius: 3px 4px; border-bottom-right-radius: 6px 2px; border-bottom-left-radius: 3px 4px;
| 初始值 |
as each of the properties of the shorthand:
|
|---|---|
| 适用于 |
all elements; but User Agents are not required to apply to
table
and
inline-table
elements when
border-collapse
is
collapse
. The behavior on internal table elements is undefined for the moment.. It also applies to
::first-letter
.
|
| 继承 | no |
| 百分比 | refer to the corresponding dimension of the border box |
| 计算值 |
as each of the properties of the shorthand:
|
| 动画类型 |
as each of the properties of the shorthand:
|
<length-percentage>{1,4} [ / <length-percentage>{1,4} ]?where
<length-percentage> = <length> | <percentage>
border: solid 10px; /* the border will curve into a 'D' */ border-radius: 10px 40px 40px 10px;
border: groove 1em red; border-radius: 2em;
background: gold; border: ridge gold; border-radius: 13em/3em;
border: none; border-radius: 40px 10px;
border: none; border-radius: 50%;
border: dotted; border-width: 10px 4px; border-radius: 10px 40px;
border: dashed; border-width: 2px 4px; border-radius: 40px;
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Backgrounds and Borders Module Level 3
The definition of 'border-radius' in that specification. |
候选推荐 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
border-radius
|
Chrome
完整支持
4
注意事项
|
Edge 完整支持 12 |
Firefox
完整支持
4
注意事项
|
IE 完整支持 9 |
Opera
完整支持
10.5
注意事项
|
Safari
完整支持
5
注意事项
|
WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 |
Firefox Android
完整支持
4
注意事项
|
Opera Android 完整支持 11 |
Safari iOS
完整支持
4.2
注意事项
|
Samsung Internet Android 完整支持 1.0 |
| Elliptical borders |
Chrome
完整支持
1
注意事项
|
Edge 完整支持 12 | Firefox 完整支持 4 | IE 完整支持 9 | Opera 完整支持 10.5 |
Safari
完整支持
3
注意事项
|
WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 4 | Opera Android 完整支持 11 | Safari iOS 完整支持 4.2 | Samsung Internet Android 完整支持 1.0 |
| 百分比 | Chrome 完整支持 8 | Edge 完整支持 12 |
Firefox
完整支持
4
注意事项
|
IE 完整支持 9 |
Opera
完整支持
11.5
注意事项
|
Safari 完整支持 5.1 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 4 | Opera Android 完整支持 11.5 | Safari iOS 完整支持 6 | Samsung Internet Android 完整支持 1.0 |
| 4 values for 4 corners | Chrome 完整支持 4 | Edge 完整支持 12 | Firefox 完整支持 4 | IE 完整支持 9 | Opera 完整支持 10.5 | Safari 完整支持 5 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 4 | Opera Android 完整支持 11 | Safari iOS 完整支持 4.2 | Samsung Internet Android 完整支持 1.0 |
完整支持
见实现注意事项。
要求使用供应商前缀或不同名称。
border-top-left-radius
,
border-top-right-radius
,
border-bottom-right-radius
,
border-bottom-left-radius
background
background-attachment
background-clip
background-color
background-image
background-origin
background-position
background-position-x
background-position-y
background-repeat
background-size
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-color
border-image
border-image-outset
border-image-repeat
border-image-slice
border-image-source
border-image-width
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
box-shadow