<body>css
<style type="text/css">spa
//只对li1设置样式ast
li:nth-child(1):nth-last-child(1){样式
background:yellow;co
}background
</style>
<h2>列表1</h2>
<ul>
<li>li1</li>
</ul>
<h2>列表2</h2>
<ul>
<li>li1</li>
<li>li2</li>
</ul>
</body>
另外:能够直接使用
li:only-child{
background:yellow;
}
来达到相同的目的。