# 可自定义文本的颜色能改吗？

**URL:** <https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666>\
**Category:** Development\
**Tags:** css\
**Created:** [2024年四月6日 00:27 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666 "2024-04-06T00:27:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BugsyB](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@BugsyB](https://meta.discourse.org/u/BugsyB)\
**Post date:** [2024年四月6日 00:27 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/1 "2024-04-06T00:27:02Z")

</div>

例如，_%{count} 未读_ 可以更改为任何我想说的内容，但我可以使 _未读_ 变成另一种颜色吗？

或者我可以添加一个背景色，就像标签周围的框一样？

谢谢。

---

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2024年四月6日 07:44 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/2 "2024-04-06T07:44:09Z")

</div>

您需要 CSS。

您需要查看 #documentation:theme-developers

---

<div class="post-metadata">

**Author:** ![BugsyB](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@BugsyB](https://meta.discourse.org/u/BugsyB)\
**Post date:** [2024年四月6日 17:58 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/3 "2024-04-06T17:58:05Z")

</div>

请问您能否提供一些实现此功能的 CSS 示例？

或者，您能否提供有关主题开发者方面的具体信息？

谢谢。

---

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [2024年四月6日 19:36 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/4 "2024-04-06T19:36:19Z")

</div>

> [@BugsyB](#):
>
> 我将_未读_设为另一种颜色

我的理解是您想更改文字而不是数字，对吗？

---

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2024年四月6日 20:27 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/5 "2024-04-06T20:27:10Z")

</div>

请阅读指南：

> [@Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/beginners-guide-to-developing-discourse-themes/93648?u=merefield):
>
> Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components. This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to: Themes vs. Theme Compon…

---

<div class="post-metadata">

**Author:** ![BugsyB](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@BugsyB](https://meta.discourse.org/u/BugsyB)\
**Post date:** [2024年四月7日 02:19 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/6 "2024-04-07T02:19:34Z")

</div>

是的。我想从自定义文本功能中进行设置。我希望将“未读”设置为红色。如果我必须在默认主题的 CSS 中添加它，我会尝试。但同样，我宁愿从自定义文本部分进行设置。

---

<div class="post-metadata">

**Author:** ![BugsyB](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@BugsyB](https://meta.discourse.org/u/BugsyB)\
**Post date:** [2024年四月7日 02:21 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/7 "2024-04-07T02:21:07Z")

</div>

但是，我不想创建一个主题。我想给自定义文本中的一个单词着色。

预计到达时间：我已经查看了您提供的链接。更改一个单词似乎太麻烦了。如果唯一的方法是创建一个新主题，对我来说也不是什么大问题。 😀

---

<div class="post-metadata">

**Author:** ![traceymoko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/traceymoko/32/483235_2.png) [@traceymoko](https://meta.discourse.org/u/traceymoko)\
**Post date:** [2024年四月7日 04:03 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/8 "2024-04-07T04:03:22Z")

</div>

> [@BugsyB](#):
>
> 我想给自定义文本中的一个单词上色。

> [@BugsyB](#):
>
> 我想让“未读”显示为红色。如果必须在默认主题中添加 CSS，我会尝试。但同样，我宁愿从自定义文本部分进行操作。

是的，如果你想改变单词的颜色和样式，就必须添加 CSS。自定义文本部分仅用于更改文本内容本身，而不是其样式。

不过，与其直接在默认主题中添加 CSS，不如使用 Discourse 的主题组件，它允许你在现有主题之上添加 CSS。

为了明确预期，Meta 并不是一个关于 CSS 入门的专门支持网站（就像它不是一个关于从头开始学习 Ruby 和 JavaScript 的专门支持网站一样，如果你想通过插件自定义 Discourse 的行为）。如果你想自定义 Discourse 的外观，你需要更多地了解 CSS。

> [@Policy notice: no basic HTML / CSS questions please](https://meta.discourse.org/t/policy-notice-no-basic-html-css-questions-please/168033):
>
> We do enjoy helping people with their free, open source Discourse instances, and that is indeed part of our responsibility to the open source community. hugs However: Over time, there has been a constant influx of basic HTML and CSS questions that are taking time away from us helping with more substantive issues specific to Discourse. It’s not a productive use of our time to teach basic HTML and CSS. There are thousands of online resources that describe how to make changes on an HTML pa…

因此，这里有关于为 Discourse 创建主题组件和插件的指南，但没有关于从头开始学习 CSS 或 Ruby 的指南（因为这是一项通用技能）。有时人们有时间乐于助人，但这并不总是可能的，因为这意味着需要回顾一般的 HTML 和 CSS 知识——检查器、类和属性等基础知识。

以下是关于在你的网站上进行 CSS 更改的入门指南：

> [@Making custom CSS changes on your site](https://meta.discourse.org/t/make-css-changes-on-your-site/168101):
>
> bookmark This guide explains how to make CSS changes on your Discourse site, including an introduction to CSS, where to add CSS in Discourse, and how to find the right selectors using browser inspection tools. person_raising_hand Required user level: Administrator Summary This guide covers: A brief introduction to CSS and key concepts How to add CSS to your Discourse site using theme components Using browser inspection tools to find the right CSS selectors Understanding CSS basics C…

---

<div class="post-metadata">

**Author:** ![BugsyB](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@BugsyB](https://meta.discourse.org/u/BugsyB)\
**Post date:** [2024年四月7日 04:25 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/9 "2024-04-07T04:25:50Z")

</div>

![](https://global.discourse-cdn.com/meta/original/4X/6/a/a/6aa6ce35a212d1cc0c992dbb8ec548baac16f22f.gif)

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2024年五月7日 04:26 UTC](https://meta.discourse.org/t/can-you-change-the-color-of-customizable-text/302666/10 "2024-05-07T04:26:27Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
