如何在 JavaScript DOM 中為底邊框設定顏色?


要為 JavaScript 中的底邊框設定顏色,請使用borderBottomColor 屬性。它允許你為邊框的底部設定邊框顏色。

示例

你可以嘗試執行以下程式碼來了解如何為底邊框設定顏色 −

即時演示

<!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.borderBottomColor = "yellow";
         }
      </script>
   </body>
</html>

更新於:2020 年 6 月 23 日

761 次檢視

開啟你的 事業

透過完成課程進行認證

開始
廣告
© . All rights reserved.