HTML - DOM樣式物件 borderTopLeftRadius 屬性



HTML DOM 樣式物件 **borderTopLeftRadius** 屬性設定或返回左上角的邊框半徑。

語法

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

屬性值

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

返回值

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

HTML DOM 樣式物件“borderTopLeftRadius”屬性示例

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

設定左上角邊框半徑

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

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopLeftRadius 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 left corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopLeftRadius = "40px";
        }
    </script>
</body>
</html>

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

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

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopLeftRadius 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 left corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopLeftRadius = "40px 100px";
        }
    </script>
</body>
</html>

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

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

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopLeftRadius 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 left corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopLeftRadius = "15%";
        }
    </script>
</body>
</html>

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

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

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object borderTopLeftRadius 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 left corner.
    </p>
    <button onclick="fun()">Change</button>
    <section id="border">
        Welcome to Tutorials Point...
    </section>
    <script>
        function fun() {
            document.getElementById("border")
                .style.borderTopLeftRadius = "15% 40%";
        }
    </script>
</body>
</html>

支援的瀏覽器

屬性 Chrome Edge Firefox Safari Opera
borderTopLeftRadius 支援 4 支援 12 支援 4 支援 5 支援 10.5
html_dom_style_object_reference.htm
廣告