HTML - DOM Style 物件 borderTopRightRadius 屬性



HTML DOM Style 物件 **borderTopRightRadius** 屬性設定或返回右上角的邊框半徑。

語法

設定 borderTopRightRadius 屬性
object.style.borderTopRightRadius= "length | percentage | initial | inherit";
獲取 borderTopRightRadius 屬性
object.style.borderTopRightRadius;

屬性值

描述
長度 它定義了右上角邊框的形狀。可以使用雙長度值來定義四分之一橢圓的半徑,其中第一個值表示水平半徑或邊框框的寬度,第二個值表示垂直半徑或邊框框的高度。它的預設值為 0。
百分比 它以百分比的形式定義了右上角邊框的形狀。可以使用雙百分比值來定義四分之一橢圓的半徑,其中第一個值表示水平半徑或邊框框的寬度,第二個值表示垂直半徑或邊框框的高度。
初始 它用於將此屬性設定為其預設值。
繼承 它用於繼承其父元素的屬性。

返回值

它返回一個字串值,表示元素的 border-top-right-radius 屬性。

HTML DOM Style 物件“borderTopRightRadius”屬性示例

以下示例說明了如何使用長度和百分比值更改右上角的邊框半徑。

設定右上角邊框半徑

以下示例使用畫素值設定右上角的邊框半徑。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopRightRadius Property
    </title>
    <style>
        section {
            border: aqua 2px solid;
            height: 400px;
            width: 400px;
            text-align: center;
        }
    </style>
</head>
<body>
    <p>
        Click to set the radius of top
        Border of right corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopRightRadius = "40px";
        }
    </script>
</body>
</html>

使用雙值設定右上角邊框半徑

以下示例使用雙長度值使用畫素值設定右上角的邊框半徑。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopRightRadius Property
    </title>
    <style>
        section {
            border: aqua 2px solid;
            height: 400px;
            width: 400px;
            text-align: center;
        }
    </style>
</head>
<body>
    <p>
        Click to set the radius of top 
        Border of right corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopRightRadius = "40px 100px";
        }
    </script>
</body>
</html>

使用百分比設定右上角邊框半徑

以下示例使用畫素百分比設定右上角的邊框半徑。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopRightRadius Property
    </title>
    <style>
        section {
            border: aqua 2px solid;
            height: 400px;
            width: 400px;
            text-align: center;
        }
    </style>
</head>
<body>
    <p>
        Click to set the radius of 
        top Border of right corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopRightRadius = "15%";
        }
    </script>
</body>
</html>

使用雙百分比值設定右上角邊框半徑

以下示例使用雙百分比值使用百分比設定右上角的邊框半徑。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopRightRadius Property
    </title>
    <style>
        section {
            border: aqua 2px solid;
            height: 400px;
            width: 400px;
            text-align: center;
        }
    </style>
</head>
<body>
    <p>
        Click to set the radius of 
        top Border of right corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopRightRadius = "15% 40%";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
borderTopRightRadius 是 4 是 12 是 4 是 5 是 10.5
html_dom_style_object_reference.htm
廣告