Can I add color to the text in post titles?

Hello everyone, I have a question: When creating a new post, is it possible to add color to the text in the title, as shown in the picture?
image

as shown in the image:
image

It’s possible to do in CSS with the attributes of topic’s “tr” tag. It has topic id, category & tag slugs, topic statuses, etc.

How should I specifically operate? Are there any detailed tutorials?

@Lhc_fl 大佬,帮我看看

Esteemed colleague, might I trouble you to cast your discerning eye over this matter?

我需要你给出更详细的信息
I need you to give more detailed information

具体来说,要以什么规则给不同的话题染上不同的颜色,你没有说明,
Specifically, you did not explain the rules for coloring different topics with different colors.

比如这样写可以让id为314580的帖子染上红色
For example, this will make the topic with id 314580 red.

image

    tr[data-topic-id="314580"] td.topic-list-data .title {
        color: red
    }
1 Like

感谢回复,请问这段代码要在哪里添加或设置?

Thank you for your response. I wonder, where should this code be added or configured?

tr[data-topic-id="314580"] td.topic-list-data .title {
        color: red
    }

Here:

我看了下,我这边只有停用的主题里有这个自定义 CSS/HTML选项,就是在这里设置吗?
I took a look, and the only theme with the custom CSS/HTML option deactivated is mine. Is this where I can set it up?

另外请问帖子的ID怎么查询,是每个帖子末尾的数字吗?
Also, how can I find the ID of a post? Is it the number at the end of each post?
image

1 Like

不知道为什么没用生效,我的代码这样写正确吗?
I don’t know why it’s not working. Is my code written correctly?

获取到的ID:
Obtained ID:
image

浏览器刷新后指定ID的主题颜色没有任何变化
After refreshing the browser, the specified theme color for the ID remains unchanged.

Does it work when you use the preview button?

Hello, I tested the preview and the pop-up page still didn’t see the specified ID’s theme color change.

我发现只有默认主题才有这个“编辑 CSS/HTML”选项,其他添加的主题没有这个选项,不过我即便启用这个默认主题,我修改过的标题颜色还是没有变化,不知道哪里步骤错了。
I found that only the default theme has the “Edit CSS/HTML” option, other added themes do not have this option. However, even if I enable the default theme, the color of the title I modified still does not change. I’m not sure where I went wrong in the process.

This is quite handy as you could color title via cat/sub or tag.

因为那几个主题都是你安装的别人预先写好的,无法修改
Because those themes you installed were pre-written by others and cannot be modified

解决方式就是尝试创建一个主题组件,然后包含在你启用的主题内
The solution is to try to create a theme component and then include it in your enabled theme


Create a theme component and add it using this:

2 Likes

Hello, I tried creating a new theme test. However, whether it is previewing the theme or switching to this theme, the title color of the corresponding ID still has not changed at all. I don’t know where else I need to make adjustments.

你好,我尝试新建了一个主题测试,无论是主题预览还是切换到这个主题,对应ID的标题颜色还是没有任何变化,不知道哪里还需要调整下

image

那你试试加上 !important 标记

tr[data-topic-id="51"] td.topic-list-data .title {
    color: red !important;
}
2 Likes

Wow! Instantly effective, you’re amazing!
哇! 瞬间生效, 你太棒了!

是优先级不够吗

1 Like

是,我懒得看具体在哪里生效了什么css

1 Like

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