小白教程
所有教程
关于
Search
172.69.58.215
172.69.58.215
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Sel only child”的源代码
本页内容
上一节:
Sel_only_of_type
下一节:
Sel_nth_child
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE::only-child}}[[Category:css selectors|31]] = CSS3 :only-child 选择器 = [[css selectors|完整CSS选择器参考手册]] 匹配属于父元素中唯一子元素的 p 元素: <sample title="" desc="" lang="html" hererun="1"> p:only-child { background:#ff0000; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> p:only-child { background:#ff0000; } </style> </head> <body> <div><p>This is a paragraph.</p></div> <div><span>This is a span.</span><p>This is a paragraph.</p></div> <p><b>注意:</b> Internet Explorer 8以及更早版本的浏览器不支持 :only-child选择器.</p> </body> </html> </run> == 定义和用法 == :only-child 选择器匹配属于父元素中唯一子元素的元素。 == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器版本号。 {| class="table table-striped table-hover" ! 选择器 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | :only-child | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |} [[css selectors|完整CSS选择器参考手册]]
返回至“
Sel only child
”。
上一节:
Sel_only_of_type
下一节:
Sel_nth_child