# 在汉堡菜单中隐藏子类别

**URL:** <https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836>\
**Category:** Support\
**Created:** [2023年一月5日 15:30 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836 "2023-01-05T15:30:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月5日 15:30 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/1 "2023-01-05T15:30:02Z")

</div>

在汉堡菜单中是否有办法隐藏子类别（仅列出父类别）？我尝试了很久，但找不到方法。

谢谢！

---

<div class="post-metadata">

**Author:** ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)\
**Post date:** [2023年一月5日 17:01 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/2 "2023-01-05T17:01:46Z")

</div>

您可以使用此 CSS 😃

```css
.hamburger-panel .category-link.subcategory {
    display: none;
}

```

---

<div class="post-metadata">

**Author:** ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)\
**Post date:** [2023年一月5日 17:20 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/3 "2023-01-05T17:20:22Z")

</div>

我过去还创建了这个主题组件：

> [@Category Hider Theme Component](https://meta.discourse.org/t/category-hider-theme-component/181299):
>
> Hi all, I’ve created a simple theme component. I hope this could be of use for some! eyeglasses Overview This is a theme component that allows you to hide specific categories from either the hamburger menu or category boxes. thinking Why would you need this component? If your discourse website has a lot of categories and you would like to hide some from appearing in either the menu bar or on the main page, this component can be helpful. framed_picture Screenshots Preview of Hambur…

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月5日 17:48 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/4 "2023-01-05T17:48:17Z")

</div>

谢谢！已添加。运行良好。

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月7日 00:25 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/5 "2023-01-07T00:25:28Z")

</div>

有一个后续问题（因为我对 CSS 一无所知），在不使用 Category Hider 的情况下，我能否添加一些 CSS 来隐藏一个特定类别？

---

<div class="post-metadata">

**Author:** ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)\
**Post date:** [2023年一月7日 06:51 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/6 "2023-01-07T06:51:59Z")

</div>

```css
.hamburger-panel .category-link.category-{{slug}} {
    display: none
}

```

例如

```css
.hamburger-panel .category-link.category-101-category {
    display: none
}
.hamburger-panel .category-link.category-general {
    display: none
}

```

要获取 slug，您可能需要按 F12 打开开发者工具。

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/6/0/f604edb4440efd39ed54c7e93bf474b54e4e1da1.png)

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月7日 12:25 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/7 "2023-01-07T12:25:49Z")

</div>

@Lhc_fl 再次感谢！

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月7日 13:02 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/8 "2023-01-07T13:02:49Z")

</div>

@keegan 我确实安装了 Category Hider Theme Component，以便将来更容易进行调整。它运行得很棒，非常感谢！

我确实注意到其设置中有一个拼写错误：

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/c/f/dcfd62c9711f4d179b458ed57212d62a57f7ea8d.png)

这不算什么大事，但我想让你知道。

---

<div class="post-metadata">

**Author:** ![keegan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keegan/32/383395_2.png) [@keegan](https://meta.discourse.org/u/keegan)\
**Post date:** [2023年一月9日 17:42 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/9 "2023-01-09T17:42:11Z")

</div>

@Loki 感谢告知，我已经推送了修复程序 🙂

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年二月9日 16:52 UTC](https://meta.discourse.org/t/suppress-subcategories-in-the-hamburger-menu/250836/10 "2023-02-09T16:52:14Z")

</div>

@keegan 我刚注意到另一个例子，其中解释性文本似乎被无意中重复了：

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/b/1/5b1faad392ab22ebf2cc8362b436001cdf2434f4.png)

我想让你知道。
