有没有办法将 "last" class 动态添加到 Tumblr 标签页中出现的最后一个 post?

Is there a way to dynamically add a "last" class to the last post appearing in a Tumblr tag page?

我想知道是否可以在 tumblr 标签页中出现的最后一个 post 添加一个“最后一个”class,以便能够在 [=19= 中对其进行自定义]?

目标如下:假设某个标签有 3 个 post,因此当我在该标签页中导航时,会出现 3 个 post,一个在另一个下面.我希望前两个由位于每个 post 正文底部的线分隔,但页面底部的最后一个在其底部不应该有分隔线,所以我想我需要一个具体 class 那个 post 因为它是最后一个。

谢谢。

根据我的评论,您只需使用 css 选择器 :last-of-type:nth-child(last)

即可实现此目的

这是一个例子。

HTML:

<div id="posts">
    <div class="post">
        Post 1
    </div>
    <div class="post">
        Post 2
    </div>
    <div class="post">
        Post 3
    </div>
</div>

CSS:

#posts .post {
    margin-bottom: 20px;
    border-bottom: 2px solid #444;
}
#posts .post:last-of-type {
    background-color: orange;
    border-bottom: none;
}

这里有一个 jsfiddle:https://jsfiddle.net/lharby/39ap851L/

所以每个 post 项目都有一个底部边框,但是对于最后一个 post 类型,我们用 border-bottom: none

覆盖它