如何在我的 wordpress blogroll 最底部的帖子中添加“底部帖子”类?我需要不同的风格。(我不能使用静态ID,因为帖子和帖子总数在不断变化)
问问题
79 次
2 回答
1
您可以使用 jQuery 向元素添加类:
$(".post:last-child").addClass("bottom-post");
然后像这样风格:
.bottom-post {
/* Different styling */
}
这种方法的一个好处(与使用纯 css 相比)是这会将类应用于元素并允许在不支持:last-child
css 选择器的浏览器上进行样式设置。我在 IE6-8 上对此进行了测试,并且在所有这些中都有效。
以下解释了为什么在这种情况下:last-child
倾向于首选伪选择器::last
于 2012-05-17T15:08:50.370 回答
1
您可以使用 CSS 伪类:last-child
来选择最后一篇文章。
例如:
.post:last-child { color: red; }
将我链接到您的博客,我将能够给出一个工作示例。
于 2012-05-17T14:54:55.330 回答