子比主题:为文章外部的标签添加随机彩色效果

机器人
摘要
Mxchild
生成中...

效果预览

子比主题:为文章外部的标签添加随机彩色效果

部署方法

1 将下面CSS代码添加至 zibil主题设置–全局&功能–自定义代码–自定义CSS样式 中即可

/*文章外部标签随机彩色*/
.item-tags a {
  padding: 5px 10px;
  border-radius: 5px;
  margin-right: 5px;
}

.item-tags a.meta-pay {
  background-color: #FFD700;  
  color: black;
}

.item-tags a.c-blue {
  background-color: #1E90FF;  
  color: white;
}

.item-tags a[href*="tag/"] {
  background-color: #FF69B4;  
  color: white;
}

2 将下面javascript代码添加至 zibil主题设置–全局&功能–自定义代码–自定义javascript代码 中即可

//文章外部标签随机彩色
var links = document.querySelectorAll('.item-tags a');
for (var i = 0; i < links.length; i++) {
  var randomColor = '#' + Math.floor(Math.random()*16777215).toString(16);
  links[i].style.backgroundColor = randomColor;
}

有单色需求自己改代码即可。

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容