如何在 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>

更新於:23-Jun-2020

92 次瀏覽

啟動你的職業

完成課程獲得認證

開始
廣告
© . All rights reserved.