使用 JavaScript 設定右上角邊框的形狀的方法是什麼?


若要在 JavaScript 中設定右上角邊框的形狀,請使用borderTopRightRadius 屬性。使用該屬性設定邊框半徑。

示例

可以嘗試執行以下程式碼,瞭解如何使用 JavaScript 設定右上角邊框的形狀。

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         #box {
            border: thick solid gray;
            width: 300px;
            height: 200px
         }
      </style>
   </head>
   <body>
      <div id="box">Demo Text</div>
      <br><br>
      <button type="button" onclick="display()">Change top right border radius</button>
      <script>
         function display() {
            document.getElementById("box").style.borderTopRightRadius = "20px";
         }
      </script>
   </body>
</html>

更新於:23-5-2020

178 次瀏覽

開啟您的 職業生涯

完成課程,獲得認證

入門
廣告
© . All rights reserved.