<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<style>
/*:only-child" 表示的是一个元素是它的父元素的唯一一个子元素
IE6-8浏览器不支持:only-child选择器*/
/*ul li:only-child{
background: red;
}*/
/*ul div:only-child{
background: yellow;
}*/
/*:only-of-type 是表示一个元素他有很多个子元素,而其中只有一个子元素是唯一的
IE6-8和FF3.0-浏览器不支持:only-of-type选择器。*/
/*ul div:only-of-type{
background: red;
color: #fff;
}*/*/
</style>
<ul>
<li>123
<div>123</div>
</li>
</ul>
<ul>
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<div>123</div>
</ul>
</body>
</html>
2.6 (案例)only-child--only-type-of
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Day 12 神句文档 The team contends that these bear more than a...
- 以下示例主要讲解nth-child、first-child、last-child、nth-of-type、firs...