<ul> <li>我是子元素1</li> <li>我是子元素2 <ol> <li>我是li的子元素</li> <li>我是li的子元素2</li> </ol> <ol> <li>我是li的子元素3</li> <li>我是li的子元素4</li> </ol> </li> </ul> <div> <button>我是一个按钮</button> </div>
ul>li:first-child{ /* 父元素的第一个子元素产生效果 */ color: red } li>ol:first-child{ background: grey } li>ol:last-child{ /* 父元素的最后一个子元素 */ background: greenyellow } div>button:only-child{ /* 仅有的一个子元素 */ background: red }