Using different styles for categories in tumblr?

╄→гoц情女王★ 提交于 2019-11-30 20:46:48

问题


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.

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


回答1:


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}">
         ....

And set up your CSS like that:

div.cars hr {
   color: blue;
}

div.motorcycles hr {
   color: red;
}

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.

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



来源:https://stackoverflow.com/questions/10183010/using-different-styles-for-categories-in-tumblr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!