--- title: border-top-left-radius slug: Web/CSS/border-top-left-radius tags: - CSS - CSS属性 - CSS边框 - CSS边框圆角 translation_of: Web/CSS/border-top-left-radius ---
border-top-left-radius 用来设置元素左上角的圆角效果。这段圆弧(角)可以是圆或椭圆的一部分。如果其中有一个值为0,那么将无圆角效果(见border-top-left-radius取值方式)。

盒模型的背景,可以是一张图片或一种颜色,会在边框处被剪裁,更甚至可以是一个圆;剪切的额外定位通过另一个CSS属性"background-clip"来定义。
/* the corner is a circle */ /* border-top-left-radius: radius */ border-top-left-radius: 3px; /* the corner is an ellipsis */ /* border-top-left-radius: horizontal vertical */ border-top-left-radius: 0.5em 1em; border-top-left-radius: inherit;
<length> 或者 <percentage>,表示左上角边框的圆角半径。<length> 或者 <percentage>,表示椭圆的水平半长轴在被用作边框左上角的半径。<length> 或者 <percentage>,表示椭圆的垂直半长轴在被用作边框左上角的半径。<length><length> 定义圆形半径或椭圆的半长轴,半短轴。不能用负值。<percentage>| 实例 | 代码 |
|---|---|
|
|
椭圆的弧被用作左上角边框
div {
border-top-left-radius: 40px 40px;
}
|
|
|
椭圆的弧被用作左上角边框
div {
border-top-left-radius: 40px 20px;
}
|
|
|
盒子是方形的,圆弧被用作左上角边框
div border-top-left-radius: 40%; } |
|
|
盒子不是方形的,椭圆的弧被用作左上角边框
div {
border-top-left-radius: 40%;
}
|
|
|
背景色在左上角被剪切
div {
border-top-left-radius:40%;
border-style: black 3px double;
background-color: rgb(250,20,70);
background-clip: content-box;
}
|
| 详细说明 | 状态 | 解释 |
|---|---|---|
| {{SpecName('CSS3 Backgrounds', '#the-border-radius', 'border-top-left-radius')}} | {{Spec2('CSS3 Backgrounds')}} | Initial definition |