在 tumblr 中为类别使用不同的样式? [英] Using different styles for categories in tumblr?

查看:29
本文介绍了在 tumblr 中为类别使用不同的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将带有不同标签(例如汽车、摩托车、轮船)的照片发布到 tumblr.然后,在帖子中,每个标签应该为每个标签显示一条不同颜色的水平线,如蓝色代表汽车,红色代表摩托车,绿色代表船舶.如果我放一张带有其他标签(例如自行车或飞机)的照片,它应该显示一条灰线.

I want to be able to post photos to tumblr with different tags (e.g. cars, motorcycles, ships). Then, in the post each tag should display a different colored horizontal line for each tag like blue for cars, red for motorcycles, and green for ships. If I put a photo with another tag like bicycles or planes it should show a grey line.

我真的找不到解决方案.

I really can't find a solution for this.

在这里,但它显示了每个帖子的所有行:http://ekoba.tumblr.com

Here it is but it shows all the lines for every post: http://ekoba.tumblr.com

推荐答案

如果您更改主题的标记以将帖子标签添加为 HTML 类,那么您可以根据标签设置 CSS 属性.例如,您将主题设置为:

If you change your theme's markup to add the post tags as HTML classes, then you can setup CSS properties based on tags. For example, you set your theme like that:

{block:Posts}
    <div class="post {TagsAsClasses}">
         ....

然后像这样设置你的 CSS:

And set up your CSS like that:

div.cars hr {
   color: blue;
}

div.motorcycles hr {
   color: red;
}

这会将 HTML 类添加到每个帖子的容器元素中,这些类基于您定义的标签,并允许您根据这些标签创建不同的样式.

This will add HTML classes to every post's container element, which are based on the tags you define, and allows you to create different styling based on those tags.

您可以查看此了解更多信息:http://www.tumblr.com/docs/en/custom_themes#posts

You can see this for more information: http://www.tumblr.com/docs/en/custom_themes#posts

这篇关于在 tumblr 中为类别使用不同的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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