小白教程
所有教程
关于
Search
172.70.131.101
172.70.131.101
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Sel required”的源代码
本页内容
上一节:
Sel_optional
下一节:
Sel_valid
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE::required}}[[Category:css selectors|50]] = CSS :required 选择器 = [[css selectors|完整CSS选择器参考手册]] 如果 input 元素设置了 "required" 属性,设置其为黄色: <sample title="" desc="" lang="html" hererun="1"> input:required { background-color: yellow; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> input:required { background-color: yellow; } </style> </head> <body> <h3>A demonstration of the :required selector.</h3> <p>An optional input element:<br><input></p> <p>A required input element:<br><input required></p> <p> :required选择器选择表单元素有“需要”属性.</p> </body> </html> </run> == 定义和使用 == :required 选择器在表单元素是必填项时设置指定样式。 表单元素可以使用 required 属性来设置必填项。 '''注意:''' :required 选择器只适用于表单元素: input, select 和 textarea。 == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器版本号。 {| class="table table-striped table-hover" ! 选择器 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | :required | 10.0 | 10.0 | 4.0 | 5.0 | 10.0 |} == CSS 语法 == <pre> :required { css 声明; } </pre> == 相关页面 == CSS 选择器 [[sel optional|:optional]] [[css selectors|完整CSS选择器参考手册]]
返回至“
Sel required
”。
上一节:
Sel_optional
下一节:
Sel_valid