為所有已啟用的設定樣式元素與 CSS


要為每個啟用的 <input> 元素設定樣式,請使用 CSS :enabled 選擇器。

示例

你可以嘗試執行以下程式碼為已啟用的 <input> 元素設定樣式

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:enabled {
            background: blue;
         }
      </style>
   </head>
   <body>
      <form action = "">
         Subject <input type = "text" name = "subject"><br>
         Student: <input type = "text" name = "student"><br>
         Age: <input type = "number" name = "age" disabled><br>
      </form>
   </body>
</html>

更新於: 30-6 月-2020

130 次瀏覽

開啟您的 職業

完成課程以獲得證書

開始
廣告