# 隐藏主题列表中的“0票”的小bug报告

**URL:** <https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309>\
**Category:** UX\
**Tags:** topic-voting\
**Created:** [2021年十二月28日 18:02 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309 "2021-12-28T18:02:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)\
**Post date:** [2021年十二月28日 18:02 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309/1 "2021-12-28T18:02:14Z")

</div>

继续讨论 [投票插件 — 在主题列表中隐藏“空”投票？](https://meta.discourse.org/t/voting-plugin-hiding-empty-votes-in-the-topic-list/206450/2)：

> [@awesomerobot](#):
>
> 之前没有，但现在有了！
> 
> [DEV: add vote count tag class by awesomerobot · Pull Request #104 · discourse/discourse-topic-voting · GitHub](https://github.com/discourse/discourse-voting/pull/104)
> 
> 此提交允许您执行以下操作：
> 
> ```plaintext
> .vote-count-0 {
> display: none;
> }
> 
> ```

如果您启用了“简单”标签显示，并且帖子至少有一个标签但没有投票，则标签列表后面会有一个逗号。

---

<div class="post-metadata">

**Author:** ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)\
**Post date:** [2021年十二月28日 18:03 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309/2 "2021-12-28T18:03:19Z")

</div>

因为：

```plaintext
.discourse-tags .discourse-tag.simple:not(:last-child)::after, .list-tags .discourse-tag.simple:not(:last-child)::after, .search-category .discourse-tag.simple:not(:last-child)::after {
	content: ", ";
	margin-left: 1px;
}

```

而且投票数即使隐藏了仍然是子元素，我猜是这样。

---

<div class="post-metadata">

**Author:** ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)\
**Post date:** [2021年十二月28日 18:07 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309/3 "2021-12-28T18:07:23Z")

</div>

最简单的解决方法是，当然，不要使用“simple”。

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2023年四月6日 18:31 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309/4 "2023-04-06T18:31:20Z")

</div>

4 个帖子被拆分到一个新主题：[如何隐藏 0 票？](https://meta.discourse.org/t/how-to-hide-0-votes/260858)

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2023年四月10日 17:12 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309/5 "2023-04-10T17:12:18Z")

</div>

> [@mattdm](#):
>
> 而且即使隐藏了，投票数仍然被视为子项，我猜是这样。

是的，当使用 CSS 隐藏时，它仍然被计算为子项，因为它仍然存在于 HTML 中。

CSS 现在大多可以处理这个问题（火狐浏览器是个例外，因为它还不支持 `:has`）……也许值得为插件添加一个真正的“在主题列表中隐藏 0 票”选项，以完全避免这个问题……但目前这样就可以了。

```scss
.vote-count-0 {
  display: none; // 隐藏 0 票数
}

.discourse-tags:has(.vote-count-0) {
  .discourse-tag:nth-last-child(2):after {
     display: none; // 隐藏倒数第二个标签上的逗号
  }
}

```

---

<div class="post-metadata">

**Author:** ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)\
**Post date:** [2025年十二月2日 13:49 UTC](https://meta.discourse.org/t/minor-bug-report-in-hiding-0-votes-from-topic-list/213309/6 "2025-12-02T13:49:33Z")

</div>


