我想知道在Tumblr中可以基于标签渲染背景吗?
我的意思是,我发布关于一般生活和我喜欢的一本书系列的文章,我希望当我发布关于生活的引用时,背景颜色是黑色,当我发布关于这本书的引用时,背景颜色是蓝色。
这是可能的吗?如果可能,如何实现?
发布于 2015-04-28 19:14:14
你可以添加一个自定义属性或类到你想要用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;
}https://stackoverflow.com/questions/29917187
复制相似问题