Different style per tagged page on Tumblr

馋奶兔 提交于 2019-12-06 12:07:32

问题


I'm trying to change the style of a tagged page on Tumblr (as in the page that collects all the specific tags - for example). At the moment all the tagged pages look the same. This is the code I've used -

{block:TagPage}
<div id="sp">
<div class="container">
<div class="row">
<h1 class="main-logo"><a href="/">
<img src="http://static.tumblr.com/bw1wxme/p5cn7shd5/logo_web.png" alt="" />
</a></h1>
</div><!-- row -->
</div><!-- /container -->
</div><!-- /portrwrap -->
{/block:TagPage}

Working example

I'm trying to use a different background for a certain tagged page. For example, when you visit the /tagged/shows page, it has a different background to the /tagged/news page.

Unlike Wordpress, I've been unable to find a page ID. I looked into this but that only changes the style of the post, not the tagged page.


回答1:


You could set an '#id' on the body element, based on the current tag:

<body {block:TagPage}id="{URLSafeTag}"{/block:TagPage} />
...
</body>

When you visit a tagged page, tagged/news/ the HTML will render like so:

<body id="news" />
...
</body>

That way you can change all elements on the page, such as the navigation.

#news #nav {
   background-color: red;
}

Hope that helps!

Reference: https://www.tumblr.com/docs/en/custom_themes#tag-pages



来源:https://stackoverflow.com/questions/24700958/different-style-per-tagged-page-on-tumblr

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