css element child select

<style>

div a:first-child{

  background-color:pink;

}

</style>

<div>

<a>Hello</a>

<a>Kitty</a>

</div>

 

会不会很好奇第7个怎么写。嘿嘿

div a:nth-child(7)  也不难。

第二个呢,可以这么写

div a:first-child+a

 

可是倒数第二个该怎么写呢?

 

最终我还是找到了css标准

http://www.w3.org/TR/selectors/#nth-last-child-pseudo

也许这个是学习css的最佳途径

 

 

posted @ 2013-11-15 20:42  Epirus  阅读(267)  评论(0编辑  收藏  举报