【问题标题】:BLOGGER Emporio give color based on labelBLOGGER Emporio 根据标签提供颜色
【发布时间】:2021-11-28 17:59:49
【问题描述】:

在主页中尝试根据标签提供颜色 .feed-view .post-wrapper .sn-p-thumbnail-container。例如标签“Italiano”背景颜色:红色和标签“英语”背景颜色:蓝色,

<b:if cond='data:view.isHomepage'><style>.feed-view .post-wrapper .snippet-thumbnail-container{background-color:red!important}</style></b:if>

使用此代码,主页中的所有缩略图都会变红,但是当我添加标签条件时...

<b:if cond='data:view.isHomepage and data:post.labels any (l =&gt; l.name == &quot;Italiano&quot;)'><style>.feed-view .post-wrapper .snippet-thumbnail-container { background-color: red !important}</style></b:if>

使用此代码根本没有颜色。 我的错误在于 post.labels 条件,但我无法准确找到错误所在。

最后只有我的主页应该是这样的:

【问题讨论】:

  • 你能提供更多代码吗,你把这个放在哪里了?
  • 这段代码放在了

标签: blogger blogger-dynamic-views


【解决方案1】:

在主题中搜索以下代码(可能出现多次,您可以全部更新,或者继续测试直到找到您需要更新的代码):

<b:includable id='postWrapperClasses'>
  <b:class cond='data:post.featuredImage' name='image'/>
  <b:class cond='not data:post.featuredImage' name='no-image'/>
  <b:class cond='data:post.labels and not data:post.labels.empty' name='has-labels'/>
</b:includable>

并添加这一行,如果帖子包含您选择的标签,这将设置一个自定义类。

<b:class cond='data:post.labels any l => l.name == "Italiano"' name='SOME-CLASS'/>

然后你可以使用 css 自定义它

.SOME-CLASS .snippet-thumbnail-container {
    background: red !important;
}

【讨论】:

  • 也许我的帖子不清楚。我已经解释过我尝试了相同结果的循环。也许检查网站会更容易。是 Kritere.com 并且由于他们不在帖子中使用图像,因此我试图根据标签在主页中为每个 .post-outer (提要中的每个帖子容器)赋予颜色。请检查添加到帖子中的图像以使其更清晰。
  • @JohnGrischam 我更新了我的答案
  • 它有效。谢谢
猜你喜欢
  • 2020-04-09
  • 2012-09-11
  • 1970-01-01
  • 1970-01-01
  • 2019-07-24
  • 1970-01-01
  • 1970-01-01
  • 2018-07-08
  • 1970-01-01
相关资源
最近更新 更多