HTML Dog
跳至导航

CSS 属性:border-radius

圆角。

指定一个四分之一圆或椭圆的半径,该四分之一圆或椭圆构成盒子边框区域外边缘的角。这是一个通用的圆角属性,不需要边框即可生效。

角部围绕指定半径的圆(或椭圆)的相应四分之一部分进行切割。

一个简写属性,组合了 border-top-left-radiusborder-top-right-radiusborder-bottom-right-radiusborder-bottom-left-radius

可能的值

注意示例
[length]为每个角设置统一的圆形半径。1em
[percentage]为每个角设置统一的椭圆半径。水平半径按边框盒宽度的百分比计算。垂直半径按边框盒子高度的百分比计算。50%
[值] [值]第一个值用于左上角和右下角。第二个值用于右上角和左下角。10px 20px
[值] [值] [值]第一个值用于左上角。第二个值用于右上角和左下角。第三个值用于右下角。10px 20px 30px
[值] [值] [值] [值]第一个值用于左上角。第二个值用于右上角。第三个值用于右下角。第四个值用于左下角。10px 20px 30px 40px
[值] / [值]第一组值指定水平半径。第二组值指定垂直半径。10px 20px / 5px 10px
inherit
initial
unset

示例


.box1 { border-radius: 10px; }
/* Corners have rounding made from a circle with a radius of 10 pixels. */

.box2 { border-radius: 10px 20px; }
/* Top-left and bottom-right corners have rounding made from a circle with a radius of 10 pixels.
   Top-right and bottom-left corners have rounding made from a circle with a radius of 20 pixels. */

.box3 { border-radius: 10px 20px 30px 40px / 5px 10px 15px 20px; }
/* Top-left corner has rounding made from an ellipse with a horizontal radius of 10 pixels and a vertical radius of 5 pixels.
   Top-right corner has rounding made from an ellipse with a horizontal radius of 20 pixels and a vertical radius of 10 pixels.
   Bottom-right corner has rounding made from an ellipse with a horizontal radius of 30 pixels and a vertical radius of 15 pixels.
   Bottom-left corner has rounding made from an ellipse with a horizontal radius of 40 pixels and a vertical radius of 20 pixels. */

浏览器支持

我可以使用 border-radius 吗? 来自 caniuse.com 的关于 border-radius 特性在主流浏览器支持情况的数据。