CSS手册
»
选择符列表
»
伪类选择符
»
相关内容:
其它伪类选择符
选择其它项
E:link
E:visited
E:hover
E:active
E:focus
E:lang(fr)
E:not(s)
E:root
E:first-child
E:last-child
E:only-child
E:nth-child(n)
E:nth-last-child(n)
E:first-of-type
E:last-of-type
E:only-of-type
E:nth-of-type(n)
E:nth-last-of-type(n)
E:empty
E:checked
E:enabled
E:disabled
E:target
@page-first
@page-left
@page-right
E:focus
版本:CSS1/2
语法:
E:focus
{ sRules }
说明:
设置对象在成为输入焦点(该对象的onfocus事件发生)时的样式。
webkit内核浏览器会默认给:focus状态的元素加上
outline
的样式。
兼容性:
浅绿
= 支持
红色
= 不支持
粉色
= 部分支持
IE
Firefox
Chrome
Safari
Opera
iOS Safari
Android Browser
Android Chrome
6.0-7.0
2.0+
4.0+
3.1+
3.5+
3.2+
2.1+
18.0+
IE8.0+
示例:
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title>用户行为伪类选择符 E:focus - CSS手册 - API参考文档</title> <style> h1 { font-size: 16px; } ul { list-style: none; margin: 0; padding: 0; } input:focus { background: #f6f6f6; color: #f60; border: 1px solid #f60; outline: none; } </style> </head> <body> <h1>请聚焦到以下输入框</h1> <form action="#"> <ul> <li><input value="姓名" /></li> <li><input value="单位" /></li> <li><input value="年龄" /></li> <li><input value="职业" /></li> </ul> </form> </body> </html>