--- title: border-radius slug: Web/CSS/border-radius tags: - CSS - CSS 属性 - CSS 边框 - Web - 参考 - 布局 translation_of: Web/CSS/border-radius ---
{{ CSSRef("CSS Borders") }}
CSS 属性 border-radius 允许你设置元素的外边框圆角。当使用一个半径时确定一个圆形,当使用两个半径时确定一个椭圆。这个(椭)圆与边框的交集形成圆角效果。

该属性是一个 简写属性,是为了将这四个属性 {{Cssxref("border-top-left-radius")}}、{{Cssxref("border-top-right-radius")}}、{{Cssxref("border-bottom-right-radius")}},和 {{Cssxref("border-bottom-left-radius")}} 简写为一个属性。
即使元素没有边框,圆角也可以用到 {{ Cssxref("background") }} 上面,具体效果受 {{ Cssxref("background-clip") }} 影响。
当 {{Cssxref("border-collapse")}} 的值为 collapse 时,border-radius 属性不会被应用到表格(
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框四角的圆角半径。只在单值语法中使用。
top-left-and-bottom-right
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框左上角和右下角的圆角半径。只在双值语法中使用。
top-right-and-bottom-left
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框右上角和左下角的圆角半径。只在双值或三值语法中使用。
top-left
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框左上角的圆角半径。只在三值或四值语法中使用。
top-right
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框右上角的圆角半径。只在四值语法中使用。
bottom-right
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框右下角的圆角半径。只在三值或四值语法中使用。
bottom-left
可以是 {{ cssxref("<length>") }} 或者 {{cssxref("<percentage>")}},表示边框左下角的圆角半径。只在四值语法中使用。
inherit
表示四个值都从父元素计算值继承。
例如:
border-radius: 1em/5em; /* 等价于: */ 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; /* 等价于: */ border-top-left-radius: 4px 2px; border-top-right-radius: 3px 4px; border-bottom-right-radius: 6px 2px; border-bottom-left-radius: 3px 4px;
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%;
示例 1 : http://jsfiddle.net/Tripad/qnGKj/2/
示例 2 : http://jsfiddle.net/Tripad/qnGKj/3/
示例 3 : http://jsfiddle.net/Tripad/qnGKj/4/
示例 4 : http://jsfiddle.net/Tripad/qnGKj/5/
示例 5 : http://jsfiddle.net/Tripad/qnGKj/6/
collapse 时 border-radius 不会生效。| Specification | Status | Comment |
|---|---|---|
| {{ SpecName('CSS3 Backgrounds', '#border-radius', 'border-radius') }} | {{ Spec2('CSS3 Backgrounds') }} |
{{cssinfo}}
{{Compat("css.properties.border-radius")}}
{{Compat("css.properties.border-radius")}}