样式没有 “required” 属性的元素和 CSS
使用 CSS 中的 :optional 选择器,为没有 “required” 属性的 <input> 元素设定样式。
示例
可以尝试运行下列代码,以实现 :optional 选择器
<!DOCTYPE html>
<html>
<head>
<style>
input:optional {
background-color: blue;
}
</style>
</head>
<body>
<form>
Subject: <input type = "text" name = "subject"><br>
Student: <input type = "text" name = "student" required><br>
</form>
</body>
</html>
广告
数据结构
计算机网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 语言编程
C++
C#
MongoDB
MySQL
JavaScript
PHP