demo http://jsfiddle.net/5m38knq7/
我希望摆脱div的最后一个边界,但它不起作用?
.content-box .item div:nth-last-of-type(1) {
border: none !important;
}
答案 0 :(得分:2)
.content-box .item div:nth-last-of-type(1)
将与div
的后代.item
匹配,而您应定位.item
(因为您在.item
上设置了边框)。所以它应该是:.content-box div.item:nth-last-of-type(1)
,但请注意,您的最后一个div包含Top
链接,因此正确的规则为.content-box div.item:nth-last-of-type(2)
答案 1 :(得分:1)
你可以使用像这样的最后一个元素
p:last-of-type
{
background:#ff0000;
}
:last-of-type选择器匹配其父元素的特定类型的最后一个子元素。
提示:这与:nth-last-of-type(1)相同。