Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 CSS3 定位特定列表项。我知道我可以使用第一个和最后一个孩子,但我需要更改第二个列表项的颜色。我以前见过这个,我认为语法包括“^”。
li:nth-child(2) { color:#ff0000; }
您使用:nth-child:
:nth-child
ul > li:nth-child(2) { color: red; }
演示:http: //jsfiddle.net/peG3S/