通过Blogger标签更改颜色 [英] Change color by Blogger Tag

查看:57
本文介绍了通过Blogger标签更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以通过标签更改某些博客区域?

is there any way to change some blogger areas by tag?

例如,我在一个带有汽车标签的页面上,仅此页面有几个部分:

Example, I'm on a page that has the tag cars, only this page would have as a few sections:

.body.header

.body .header

与其他页面有不同的颜色吗?

have a different color from other pages?

我得到了一个脚本,该脚本每12小时会更改网站的背景颜色,但这仍然不是我想要的,我想要的是随着标记的更改而更改博客的一部分

I got this script that changes the background color of the site every 12 hours, but it's still not what I'm looking for, what I would like was to change parts of the blog as the tag changed

<script type='text/javascript'>//<![CDATA[ 
    var currentTime = new Date().getHours();
    if (6 <= currentTime && currentTime < 12) {
        document.body.style.backgroundColor = "#1abc9c";
    } else if (12 <= currentTime && currentTime < 18) {
        document.body.style.backgroundColor = "#318fcb";
    } else {
        document.body.style.backgroundColor = "#560256";
    }
//]]></script>

更多信息:

我知道可以使用此代码进行更改,但是更改仅在标签页面上发生,因为更改发生在所有带有car标签的页面上.

I know it is possible to use this code to make the changes happen, but the changes only happen on the label page, as the changes happen on all pages that have the car tag.

<b:if cond='data:blog.searchLabel == "car"'>
   <style type='text/css'>
       body { background: #e2ad44 !important }
   </style>
</b:if>

推荐答案

问题末尾的代码段将在标签"页面中完美显示.在文章页面中,您需要类似的代码来检查帖子是否具有特定标签,因此您需要在主博客帖子循环中添加下一个代码:

The snippet in the end of your question will work perfectly in labels page. In article page you need a similar code to check if post has a specific tag, so you need to add the next code within main blog posts loop:

<!-- check if page type is article page & check if article has a "car" tag -->
<b:if cond='data:view.isPost and data:post.labels any (l => l.name == "car")'>
  <style>
    body { background: #e2ad44 }
  </style> 
</b:if>

这篇关于通过Blogger标签更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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