如何使用 JavaScript 一次性設定所有四個邊框半徑屬性?


要使用 JavaScript 設定所有邊框半徑屬性,請使用 borderRadius 屬性。使用此屬性一次性設定邊框半徑屬性。

示例

你可以嘗試執行以下程式碼來學習如何設定所有四個邊框半徑屬性 −

動態演示

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

更新於: 2020 年 6 月 23 日

118 次瀏覽

啟動你的 職業

獲得認證,完成課程

開始
廣告
© . All rights reserved.