CSS 的作用:disabled 选择器


使用 CSS :disabled 选择器来设置所有已禁用 <input> 元素的样式。你可以尝试运行以下代码来实现 :disabled 选择器

示例

现场演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:enabled {
            background: blue;
         }
         input:disabled {
            background: red;
         }
      </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>

更新于:2020 年 6 月 30 日

182 次浏览

职业生涯起步

通过完成课程进行认证

开始
广告
© . All rights reserved.