使用 CSS 为没有"readonly"属性的输入元素添加样式

cssweb developmentfront end technology更新于 2025/6/4 17:16:17

使用 CSS: read-write 选择器选择没有"readonly"属性的元素。

示例

您可以尝试运行以下代码来实现: read-write 选择器

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:read-write {
            background-color: blue;
            color: white;
         }
      </style>
   </head>
   <body>
      <form>
         Subject: <input type = "text" name = "subject" value = "Java"><br>
         Student: <input type = "text" name = "student" readonly value = "Amit"><br>
      </form>
   </body>
</html>

相关文章


有用资源