Defining style per tags in Tumblr

混江龙づ霸主 提交于 2019-12-04 14:35:37

问题


I would like to know how to define the specific style for specific tags. For instance, I would like to have my posts render a certain style if they're tagged with Croissant or Chocolate.

I think know I have to create a new class and I know I have to style this new class but I don't know how to do it.

Thanks for the help!


回答1:


You'll need to use {TagsAsClasses} in your theme.

For example, you'll need to write something like for your theme:

<div id="{PostID}" class="post {PostType} {TagsAsClasses}">
  <!-- ... -->
</div>

If your post is a photo post and has the tags Croissant and Chocolate, then your HTML becomes:

<div id="post-26107509778" class="post photo Croissant Chocolate">
  <!-- ... -->
</div>

and then you can set the styles for the .Croissant or .Chocolate classes:

.Croissant {
  /* add your styles here */
}

.Chocolate {
  /* add your styles here */
}

More info here http://www.tumblr.com/docs/en/custom_themes



来源:https://stackoverflow.com/questions/11523662/defining-style-per-tags-in-tumblr

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