0

我想知道是否可以根据 Tumblr 中的标签渲染背景?

我的意思是,我发布关于一般生活和我喜欢的系列丛书的帖子,我希望当我发布关于生活的引用时,背景颜色是黑色,当我发布关于书的引用时,背景颜色是蓝色的。

这可能吗?如果可以,怎么做?

4

2 回答 2

2

您可以使用 jQuery 向要更改其背景的元素添加自定义属性或类,如下所示:

$(document).ready(function(){
  var tag = $('select the element where your tag is').text(); 
/*If there are more than one tag you'll have to work with 
the string to select //only the one you want, maybe with 
a switch if you have a limited number of options*/
  $('body').addClass(tag);
})

然后,使用 css,您可以使用如下选择器进行更改:

body.tag{
   background: #yourcolor;
}
于 2015-04-28T11:14:14.077 回答
0

将课程添加到您的帖子中{TagsAsClasses}。然后用“生活”标记所有生活帖子,用“书”标记所有帖子。

然后你可以这样设计:

.life { background-color: black; }

.book { background-color: blue; }
于 2016-12-13T00:49:06.343 回答