第一个孩子和最后一个孩子没有css的功能

时间:2012-08-06 23:18:06

标签: css

第一个孩子应该将图像图标设为主页,最后一个孩子不应该显示背景图像:

继承人:http://jsfiddle.net/gUqC2/

但第一个孩子没有显示任何图片,并且最后一个孩子没有删除图片

2 个答案:

答案 0 :(得分:2)

您似乎对类和伪选择器感到困惑,伪选择器:first-child 不等同于.first(类名)。同样,:last-child不等同于.last(同样是类名)。

使用:

.bodyheader ul li:first-child a:hover { background-position: 0 -16px; }
.bodyheader ul li:last-child { background: none; margin-right: 0; padding-right: 0; }

Updated JS Fiddle

参考文献:

答案 1 :(得分:1)

使用:first-child:last-child代替.first.last

.whatever引用包含class="whatever"的元素,而:first-child:last-child是伪选择符,因为您已使用:hover链接