如何在 JavaScript DOM 中一次設定所有邊框底部屬性?


要在 JavaScript 中一次設定邊框底部屬性,請使用 borderBottom 屬性。它允許你設定 border-bottom-width、border-bottom-style 和 border-bottom-color。

示例

你可以嘗試執行以下程式碼來學習如何設定邊框底部屬性 -

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         #box {
            border: 2px dashed blue;
            width: 120px;
            height: 120px;
         }
      </style>
   </head>
   <body>
      <button onclick="display()">Set border bottom color</button>
      <div id="box">
         <p>Demo Text</p>
         <p>Demo Text</p>
      </div>
      <script>
         function display() {
            document.getElementById("box").style.borderBottom = "thin dashed #000000";
         }
      </script>
   </body>
</html>

更新於: 2020 年 6 月 23 日

92 次瀏覽

開啟你的 職業生涯

完成課程,獲得認證

開始學習
廣告
© . All rights reserved.