butterfly主题添加Volantis主题标签

前言

声明:参考:会飞的小戈

移植Volantis主题标签的样式到butterfly主题,需要在原生butterfly主题适配
那么需要对css和js的添加,对主题的修改有以下两个方法:

  1. 外部挂件代码(推荐)->原因:稳定性高,可以平滑升级,没到必要时候是不需要修改源码滴
  2. 直接修改源代码

如何添加Volantis主题css和js

  • 打开主题目录下的配置文件,ctrl+F快速找到以下代码
inject:
  head:
   - <link rel="stylesheet" href="挂载路径以及文件名">
  bottom:
   - <script src="挂载路径以及文件名"></script>

说明
1.一般来讲, 在head处挂载css代码,在bottom处挂载js代码
2. css代码放在\Butterfly\source\css目录下,js代码放在\Butterfly\source\js目录下

我的挂载配置如下,具体的话按照自己的需要来吧!


inject:
  head:
  # 外挂插件
  - <link rel="stylesheet" href="/css/VolantisTags.css">
  - <link rel="stylesheet" href="/css/friendlink.css">
  bottom:
    - <script src="/js/calendar.js"></script>
    - <script src="/js/languages.js"></script>
    # 外挂插件
    - <script src="/js/VolantisTags.js"></script>

  • 示例:
    1. 添加css样式文件,如图:
      在这里插入图片描述

    2. 添加js脚本,如图:

      在这里插入图片描述

css和js

JS:

/* eslint-disable */
(function ($) {
   
    "use strict";
    function setTabs() {
   
      const $tabs = $(".tabs");
      if ($tabs.length === 0) return;
      let $navs = $tabs.find(".nav-tabs .tab");
      for (var i = 0; i < $navs.length; i++) {
   
        let $a = $tabs.find($navs[i].children[0]);
        $a.addClass($a.attr("href"));
        $a.removeAttr("href");
      }
      $(".tabs .nav-tabs").on("click", "a", (e) => {
   
        e.preventDefault();
        e.stopPropagation();
        let $tab = $(e.target.parentElement.parentElement.parentElement);
        $tab.find(".nav-tabs .active").removeClass("active");
        $tab.find(e.target.parentElement).addClass("active");
        $tab.find(".tab-content .active").removeClass("active");
        $tab.find($(e.target).attr("class")).addClass("active");
        return false;
      });
    }
  
    $(function () {
   
      setTabs();
      // $(".article .video-container").fitVids();
      $(".scroll-down").on("click", function () {
   
        scrolltoElement(".l_body");
      });
      setTimeout(function () {
   
        $("#loading-bar-wrapper").fadeOut(500);
      }, 300);
    });
  })(jQuery);

CSS

* {
   
  box-sizing: border-box;
  outline: none;
  margin: 0;
  padding: 0;
}
details {
   
  display: block;
  padding: 20px;
  margin: 0.5rem 0;
  border-radius: 4px;
  background: #fff;
  font-size: 0.9375rem;
  transition: all 0.28s ease;
  -moz-transition: all 0.28s ease;
  -webkit-transition: all 0.28s ease;
  -o-transition: all 0.28s ease;
  border: 1px solid #f6f6f6;
}
summary {
   
  display: block;
}
details summary {
   
  cursor: pointer;
  padding: 16px;
  margin: -20px;
  border-radius: 4px;
  color: rgba(85, 85, 85, 0.7);
  font-size: 0.875rem;
  font-weight: bold;
  position: relative;
  line-height: normal;
}
details summary > p,
details summary > h1,
details summary > h2,
details summary > h3,
details summary > h4,
details summary > h5,
details summary > h6 {
   
  display: inline;
  border-bottom: none !important;
}
details summary:hover {
   
  color: #555;
}
details summary:hover:after {
   
  position: absolute;
  content: "+";
  text-align: center;
  top: 50%;
  transform: translateY(-50%);
  right: 16px;
}
details > summary {
   
  background: #f6f6f6;
}
details[blue] {
   
  border-color: #e8f4fd;
}
details[blue] > summary {
   
  background: #e8f4fd;
}
details[cyan] {
   
  border-color: #e8fafe;
}
details[cyan] > summary {
   
  background: #e8fafe;
}
details[green] {
   
  border-color: #ebf9ed;
}
details[green] > summary {
   
  background: #ebf9ed;
}
details[yellow] {
   
  border-color: #fff8e9;
}
details[yellow] > summary {
   
  background: #fff8e9;
}
details[red] {
   
  border-color: #feefee;
}
details[red] > summary {
   
  background: #feefee;
}
details[open] {
   
  border-color: rgba(85, 85, 85, 0.2);
}
details[open] > summary {
   
  border-bottom: 1px solid rgba(85, 85, 85, 0.2);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
details[open][blue] {
   
  border-color: rgba(33, 150, 243, 0.3);
}
details[open][blue] > summary {
   
  border-bottom-color: rgba(33, 150, 243, 0.3);
}
details[open][cyan] {
   
  border-color: rgba(27, 205, 252, 0.3);
}
details[open][cyan] > summary {
   
  border-bottom-color: rgba(27, 205, 252, 0.3);
}
details[open][green] {
   
  border-color: rgba(61, 197, 80, 0.3);
}
details[open][green] > summary {
   
  border-bottom-color: rgba(61, 197, 80, 0.3);
}
details[open][yellow] {
   
  border-color: rgba(255, 189, 43, 0.3);
}
details[open][yellow] > summary {
   
  border-bottom-color: rgba(255, 189, 43, 0.3);
}
details[open][red] {
   
  border-color: rgba(254, 95, 88, 0.3);
}
details[open][red] > summary {
   
  border-bottom-color: rgba(254, 95, 88, 0.3);
}
details[open] > summary {
   
  color: #555;
  margin-bottom: 0;
}
details[open] > summary:hover:after {
   
  content: "-";
}

details[open] > div.content {
   
  padding: 16px;
  margin: -16px;
  margin-top: 0;
}





/*note标签*/


div.note {
   
  position: relative;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.6rem 16px 0.5rem 16px;
  padding-left: calc(16px + 16px);
  border-radius: 4px;
  background: #f6f6f6;
  border-left: 4px solid #767676;
}
div.note h2,
div.note h3,
div.note h4,
div.note h5,
div.note h6 {
   
  margin-top: 3px;
  margin-bottom: 0;
  padding-top: 0 !important;
  border-bottom: initial;
}
div.note p,
div.note ul,
div.note ol,
div.note blockquote,
div.note img {
   
  font-size: 14px;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}
div.note::before {
   
  position: absolute;
  top: calc(50% - 24px * 0.5);
  left: 4px;
  width: 24px;
  height: 24px;
  text-align: center;
  font-weight: 600;
  line-height: 24px;
  vertical-align: middle;
  font-family: 'Font Awesome 5 Free';
}
div.note::before {
   
  color: #767676;
  content: '\f054';
}
div.note::before 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值