如何使用 JavaScript 在單條宣告中設定所有的 outline 屬性?
要在一份宣告中設定所有 outline 屬性,請使用 outline 屬性。它設定以下屬性:outline-width、outline-style 和 outline-color。
範例
你可以嘗試執行以下程式碼來了解如何處理 outline 屬性 −
<!DOCTYPE html> <html> <head> <style> #box { border: 2px dashed blue; } </style> </head> <body> <div id="box">This is a div.</div> <br> <button type="button" onclick="display()">Click to set Outline</button> <script> function display() { document.getElementById("box").style.outline = "5px solid red"; } </script> </body> </html>
廣告