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:only-child
版本:CSS3
语法:
E:only-child
{ sRules }
说明:
匹配父元素仅有的一个子元素E。
要使该属性生效,E元素必须是某个元素的子元素,E的父元素最高是body,即E可以是body的子元素
兼容性:
浅绿
= 支持
红色
= 不支持
粉色
= 部分支持
IE
Firefox
Chrome
Safari
Opera
iOS Safari
Android Browser
Android Chrome
6.0-8.0
2.0+
4.0+
3.1+
3.5+
3.2+
2.1+
18.0+
IE9.0+
示例:
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title>结构性伪类选择符 E:only-child - CSS手册 - API参考文档</title> <style> h1 { font-size: 16px; } li:only-child { color: #f00; } </style> </head> <body> <h1>只有唯一一个子元素</h1> <ul> <li>结构性伪类选择符 E:only-child</li> </ul> <h1>有多个子元素</h1> <ul> <li>结构性伪类选择符 E:only-child</li> <li>结构性伪类选择符 E:only-child</li> <li>结构性伪类选择符 E:only-child</li> </ul> </body> </html>