CSS border-top-right-radius 属性

CSS border-top-right-radius 定义了元素右上角的圆形。

此属性是 CSS3 属性之一。

有三种类型的圆形。
可以是圆也可以是椭圆,或者值为0,角为正方形。
如果我们使用背景图像或者颜色,它将在边框处被剪裁。

剪辑的过程由 background-clip 属性的值定义。

该属性有两个值:长度和百分比。
border-top-right-radius 属性指定水平和垂直半径,用于定义边框的圆角右上角。
当仅给出一个值时,该值指定椭圆的水平半径和垂直半径。
如果有两个值,第一个设置水平半径,第二个设置垂直半径。
水平半径的百分比是指盒子的宽度,垂直半径的百分比是指盒子的高度。
不允许使用负值。

初始值0
应用于所有元素。它也适用于::first-letter。
继承无效
可动画的右上边框可设置动画。
版本CSS3
DOM 语法object.style.borderTopRightRadius=“25px”;

语法

border-top-right-radius: length | % | initial | inherit;

让我们尝试一个仅使用一个值的示例。
它定义了椭圆的上边框和右边框。

border-top-right-radius 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        height: 40px;
        background: #666;
        border: 4px solid #000000;
        border-top-right-radius: 35px;
      }
    </style>
  </head>
  <body>
    <h2>Border-top-right-radius 示例</h2>
    <div></div>
  </body>
</html>

在下面的示例中,第一个定义椭圆的上边框,第二个表示椭圆的右边框。

具有两个值的 border-top-right-radius 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        height: 40px;
        background: #666;
        border: 4px solid #000000;
        border-top-right-radius: 35px 10px;
      }
    </style>
  </head>
  <body>
    <h2>Border-top-right-radius 示例</h2>
    <div></div>
  </body>
</html>

以百分比表示的 border-top-right-radius 属性示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        height: 40px;
        background: #1c87c9;
        border: 4px solid #000000;
        border-top-right-radius: 60% 30%;
      }
    </style>
  </head>
  <body>
    <h2>Border-top-right-radius 示例</h2>
    <div></div>
  </body>
</html>

CSS border-top-right-radius 属性值说明

说明
length定义左上角的圆形。
%定义左上角的圆形形状(单位为%)。
initial将属性设置为其默认值。
inherit从父元素继承属性。
日期:2020-06-02 22:14:20 来源:oir作者:oir