有没有办法让 Tumblr 上的每个标签都不同颜色? [英] Is there a way to every tag on Tumblr different color?

查看:36
本文介绍了有没有办法让 Tumblr 上的每个标签都不同颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想在我的 Tumblr 主题上制作三种颜色作为标签背景,但如果我乘以

So, I wanted to make three colors as tags background on my Tumblr theme, but if I multiply

<a href="{TagURL}">{Tag}</a>

我只是获得了更多标签.

I just get more tags.

我希望第一个标签背景为红色,第二个为蓝色,第三个为绿色,然后第四个为红色,依此类推...这可能吗?

I wanted first tag background to be red, second to be blue, third to be green, then fourth to be red again, and so on, and so on... Is that possible?

推荐答案

您可以使用 设置页面内容的样式CSS.通常您会使用 classid 选择器来为每个标签设置不同的样式.但是因为 Tumblr 上的标签没有唯一的类/ID,你可以使用伪类 nth-child.您可以在那里找到规范:http://www.w3.org/TR/selectors/#nth-child-pseudo(也包含一些示例).

You can style the page content with CSS. Usually you'd use class or id selectors to style each tag differently. But because the tags at Tumblr won't have unique classes/IDs, you can make use of the pseudo-class nth-child. You can find the specification there: http://www.w3.org/TR/selectors/#nth-child-pseudo (contains some examples, too).

css-tricks.com 上的相关博客文章:nth-child 的工作原理

Related blog post at css-tricks.com: How nth-child Works

您还可以编辑您的主题并将类添加到您的标签中.请参阅问题对 tumblr 中的类别使用不同样式?答案 解释了它. 啊不,这将类添加到整个帖子的容器中.因此,如果贴有特定标签,您可以为帖子设置不同的样式.但这不是你想要的.您可以添加变量 {Tag}(这将是标签名称)到标签的标记,不过.使用这种方法,您必须手动定义哪些标签应该获得哪种颜色,这可能不是您想要的.

You could also edit your theme and add classes to your tags. See the question Using different styles for categories in tumblr? and the answer that explains it. Ah no, this adds the classes to the container of the whole post. So you could style a post differently if it is tagged with a certain tag. But that is not what you want. You could probably add the variable {Tag} (which would be the tag name) to the markup of the tag, though. With this method you'd have to define which tags should get which color manually, which might not be what you want.

这篇关于有没有办法让 Tumblr 上的每个标签都不同颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆