設定樣式,為每個啟用的元素設定樣式,用 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-06-2020

130 次瀏覽

開啟你的 職業

完成課程,獲得認證

立即開始
廣告