# 我如何将类别文本对齐配置为居中？

**URL:** https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930
**Category:** Development
**Tags:** category-banners
**Created:** [2024年八月9日 16:34 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930 "2024-08-09T16:34:07Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![oga](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@oga](https://meta.discourse.org/u/oga)
#### Post date: [2024年八月9日 16:34 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/1 "2024-08-09T16:34:07Z")

</div>

首先，请看官方 Discourse 分类标题。请注意它们在标题显示中是如何居中的，就像这样：

 ![Screenshot 2024-08-09 at 12.21.02 PM](https://global.discourse-cdn.com/meta/original/4X/6/9/f/69f509584343c8cd1353af6b0363ee78f42954e6.png)  
 ![Screenshot 2024-08-09 at 12.23.01 PM](https://global.discourse-cdn.com/meta/original/4X/6/c/9/6c9ca4a83b57586d2bca4e60d89f61625afaea45.png)  
请注意标题和下方的文本都是居中的吗？  
现在看看我的。  
 ![Screenshot 2024-08-09 at 12.21.38 PM](https://global.discourse-cdn.com/meta/original/4X/a/f/2/af2ba09b63d24732aa95c57de72ff95daa69e58b.png)  
我的文本是左对齐的。  
我已经进入了“分类主题组件”并设置了“Text-Align”为“Center”，但结果并不相同。我哪里做错了？  
谢谢。

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2024年八月9日 16:39 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/2 "2024-08-09T16:39:46Z")

</div>

这是 [Category Banners](https://meta.discourse.org/t/category-banners/86241/230) 组件。嗯，我刚测试了一下，它对我来说工作正常。看起来你可能有一些其他的 CSS 导致了这个问题……

> [@我的类别名称左对齐了，如何居中？](https://meta.discourse.org/t/my-category-name-is-aligned-to-the-left-how-to-center-it/278665/2?u=lilly):
>
> 听起来您有另一个组件或一些 CSS 代码将其对齐到左侧。默认是居中，这就是为什么当您从组件预览时它会居中的原因。我建议删除一些可能与之冲突的其他主题组件，直到找到罪魁祸首，然后您可能需要进行一些代码更改或其他操作来修复它。

---

<div class="post-metadata">

### Author: ![oga](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@oga](https://meta.discourse.org/u/oga)
#### Post date: [2024年八月9日 16:41 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/3 "2024-08-09T16:41:47Z")

</div>

有意思。我甚至没有添加任何其他 CSS，所以你的测试是在完全相同的 Theme Component 上进行的吗？

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2024年八月9日 16:44 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/4 "2024-08-09T16:44:12Z")

</div>

是的。转到主题组件，确保“对齐文本”设置为“居中”，然后单击底部的“预览”按钮，看看对齐方式是否已修复？如果修复了，那么您就有另一个主题组件或 CSS 在更改它。

 ![Screenshot 2024-08-09 at 9.44.55 AM](https://global.discourse-cdn.com/meta/original/4X/3/f/5/3f508daca599668ac9e20614e91a6deaef5e5d82.png)

 ![Screenshot 2024-08-09 at 9.45.27 AM](https://global.discourse-cdn.com/meta/original/4X/5/4/4/544bed1420a757da9ac05679dad67cd6b617e461.png)

结果：

 ![Screenshot 2024-08-09 at 9.46.48 AM](https://global.discourse-cdn.com/meta/original/4X/6/3/0/630f2ea6d13dc41bf647c5a7d2a8c49ca0802cc7.png)

---

<div class="post-metadata">

### Author: ![oga](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@oga](https://meta.discourse.org/u/oga)
#### Post date: [2024年八月9日 16:55 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/5 "2024-08-09T16:55:41Z")

</div>

奇怪，我的也和你的一样。我使用的是 Mint 主题，没有其他设置。

 ![Screenshot 2024-08-09 at 12.52.26 PM](https://global.discourse-cdn.com/meta/original/4X/6/a/8/6a81c1684ece0bbd7a3a0c1e641ef74a03a97fc1.png)  
 ![Screenshot 2024-08-09 at 12.52.55 PM](https://global.discourse-cdn.com/meta/original/4X/2/a/b/2abfafc53e621f2c7cffc8799fc278b0610ab6fb.png)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2024年八月9日 16:57 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/6 "2024-08-09T16:57:29Z")

</div>

您尝试过类别横幅组件的预览吗？

> [@Lilly](#):
>
> 转到主题组件并确保“文本对齐”设置为“居中”，然后单击底部的“预览”按钮，看看对齐是否已修复？

---

<div class="post-metadata">

### Author: ![oga](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@oga](https://meta.discourse.org/u/oga)
#### Post date: [2024年八月9日 16:58 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/7 "2024-08-09T16:58:40Z")

</div>

是的，我做了。

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2024年八月9日 17:02 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/8 "2024-08-09T17:02:05Z")

</div>

我刚用薄荷主题测试了一下，效果符合预期

 ![Screenshot 2024-08-09 at 10.01.47 AM](https://global.discourse-cdn.com/meta/original/4X/c/e/3/ce346a681bd5c68de74564fe670a0def604f102e.jpeg)

---

<div class="post-metadata">

### Author: ![oga](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@oga](https://meta.discourse.org/u/oga)
#### Post date: [2024年八月9日 17:04 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/9 "2024-08-09T17:04:22Z")

</div>

那我的也是错的。非常感谢。

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2024年八月9日 17:06 UTC](https://meta.discourse.org/t/how-do-i-configure-category-text-align-to-center/320930/10 "2024-08-09T17:06:41Z")

</div>

也许可以尝试重新安装 Mint 主题和 Category Banners 组件。我曾以为是 Featured Categories 组件（它是 Mint 的一部分）在干扰，但似乎不是。
