handsome主题的特效与美化技巧(2)

标签页title显示

切换标签离开当前页面时改变title提示,就像我的这个一样,离开当前页面显示的是你有正在进行的操作哦!,回来显示默认的title。

进入后台开发者选项自定义JS设置。

代码如下:

<script>document.addEventListener('visibilitychange',function(){if(document.visibilityState=='hidden'){normal_title=document.title;document.title='这里填写你要显示的title';}else{document.title=normal_title;}});</script>
//在当前页面normal_title也可以改成你自己的设置

自定义JS中去掉<script> </script>

博主介绍的闪字特效

将以下代码加入博主介绍中,显示内容可自行修改。

<span class="text-muted text-xs block"><div id="chakhsu"></div> <script> var chakhsu = function (r) {function t() {return b[Math.floor(Math.random() * b.length)]} function e() {return String.fromCharCode(94 * Math.random() + 33)} function n(r) {for (var n = document.createDocumentFragment(), i = 0; r > i; i++) { var l = document.createElement("span"); l.textContent = e(), l.style.color = t(), n.appendChild(l) } return n}function i() {var t = o[c.skillI]; c.step ? c.step-- : (c.step = g, c.prefixP < l.length ? (c.prefixP >= 0 && (c.text += l[c.prefixP]), c.prefixP++) : "forward" === c.direction ? c.skillP < t.length ? (c.text += t[c.skillP], c.skillP++) : c.delay ? c.delay-- : (c.direction = "backward", c.delay = a) : c.skillP > 0 ? (c.text = c.text.slice(0, -1), c.skillP--) : (c.skillI = (c.skillI + 1) % o.length, c.direction = "forward")), r.textContent = c.text, r.appendChild(n(c.prefixP < l.length ? Math.min(s, s + c.prefixP) : Math.min(s, t.length - c.skillP))), setTimeout(i, d) } /*以下内容自定义修改*/ var l = "*", o = ["露从今夜白,月是故乡明" ].map(function (r) {return r + ""}), a = 2, g = 1, s = 5, d = 75, b = ["rgb(110,64,170)", "rgb(150,61,179)", "rgb(191,60,175)", "rgb(228,65,157)", "rgb(254,75,131)", "rgb(255,94,99)", "rgb(255,120,71)", "rgb(251,150,51)", "rgb(226,183,47)", "rgb(198,214,60)", "rgb(175,240,91)", "rgb(127,246,88)", "rgb(82,246,103)", "rgb(48,239,130)", "rgb(29,223,163)", "rgb(26,199,194)", "rgb(35,171,216)", "rgb(54,140,225)", "rgb(76,110,219)", "rgb(96,84,200)"], c = {text: "", prefixP: -s, skillI: 0, skillP: 0, direction: "forward", delay: a, step: g}; i() }; chakhsu(document.getElementById('chakhsu')); </script> </span> </span>

彩色标签云

1、替换sidebar.php文件中标签云为以下代码

<section id="tag_cloud-2" class="widget widget_tag_cloud wrapper-md clear"> <h3 id="tag-cloud-title" class="widget-title m-t-none text-md"><?php _me("标签云") ?></h3> <?php Typecho_Widget::widget('Widget_Metas_Tag_Cloud','ignoreZeroCount=1&limit=30')->to($tags); ?> <?php if($tags->have()): ?> <?php while ($tags->next()): ?> <span id="tag-clould-color" style="background-color:rgb(<?php echo(rand(0,255)); ?>,<?php echo(rand(0,255)); ?>, <?php echo(rand(0,255)); ?>)"> <a href="<?php $tags->permalink();?>"> <?php $tags->name(); ?></a> </span> <?php endwhile; ?> <?php endif; ?> </section>

assets--css--新建任意名称的CSS文件(例:biaoqian.css

#tag-clould-color { padding: 5px 10px 5px 10px; border-radius: 10px; color: #FFFFFF; margin: 3px 3px 3px 0; display: inline-block; }

header.php中引用此CSS文件(位置放在英文字体文件后即可)

<link rel="stylesheet" href="<?php echo STATIC_PATH; ?>css/filename.css" type="text/css">

顶部导航天气

  1. 进入https://www.seniverse.com注册账号
  2. 进入https://www.seniverse.com/widget/get根据自己的博客主题配置样式
  3. 将获得的代码添加在/handsome/component/headnav.php中适当的位置,推荐放在搜索前后
需要将<div id="tp-weather-widget">
改成<div id="tp-weather-widget" class="navbar-form navbar-form-sm navbar-left shift">
<!--搜索提示-->
                <!--<ul class="dropdown-menu" style="display: block; top: 30px; left: 0px;">
                    <li tabindex="0" style="">
                        <a>友人C</a>
                    </li>
                </ul>-->
              <span id="search_submit" class="transparent input-group-btn">
                  <button  type="submit" class="transparent btn btn-sm"><i class="fontello fontello-search"></i></button>
              </span>
            </div>
          </div>
        </form>

                              在此处插入代码

          <a href="" style="display: none" id="searchUrl"></a>
        <!-- / search form -->

网站顶部添加一个彩色横条

打开后台设置-插件-设置外观-开发者设置-自定义CSS,添加以下代码

#nav-img {
    background: url(https://ww1.sinaimg.cn/large/005BYqpgly1frxxthabo4g30ag004dfs.jpg);
    height:4px;
    top:0px;
    position: fixed;
    width:100%;
    Z-index:9999;
}

打开后台设置-插件-设置外观-开发者设置-自定义输出head头部的HTML代码,添加以下Html代码。

<div id="nav-img"></div>

效果:
697408147.jpg

鼠标点击特效

放置于usr/themes/handsome/component/footer.php <?php $this->options->bottomHtml(); ?之前

  1. 文字特效
#字体自行修改
<script type="text/javascript"> 
/* 鼠标特效 */
var a_idx = 0; 
jQuery(document).ready(function($) { 
    $("body").click(function(e) { 
        var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善"); 
        var $i = $("<span/>").text(a[a_idx]); 
        a_idx = (a_idx + 1) % a.length; 
        var x = e.pageX, 
        y = e.pageY; 
        $i.css({ 
            "z-index": 999999999999999999999999999999999999999999999999999999999999999999999, 
            "top": y - 20, 
            "left": x, 
            "position": "absolute", 
            "font-weight": "bold", 
            "color": "#ff6651" 
        }); 
        $("body").append($i); 
        $i.animate({ 
            "top": y - 180, 
            "opacity": 0 
        }, 
        1500, 
        function() { 
            $i.remove(); 
        }); 
    }); 
}); 
</script>
  1. 小爱心特效
<script type="text/javascript">
 
     !function (e, t, a) {
          function r() {
             for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el),           s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" +   s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," +   s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
             requestAnimationFrame(r)
        }
 
         function n() {
             var t = "function" == typeof e.onclick && e.onclick;
             e.onclick = function (e) {
                 t && t(), o(e)
            }
         }
 
         function o(e) {
             var a = t.createElement("div");
             a.className = "heart", s.push({
                  el: a,
                 x: e.clientX - 5,
                 y: e.clientY - 5,
                 scale: 1,
                 alpha: 1,
                 color: c()
            }), t.body.appendChild(a)
         }
 
          function i(e) {
            var a = t.createElement("style");
             a.type = "text/css";
             try {
                 a.appendChild(t.createTextNode(e))
             } catch (t) {
                a.styleSheet.cssText = e
             }
             t.getElementsByTagName("head")[0].appendChild(a)
         }
 
         function c() {
             return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 *    Math.random()) + ")"
         }
 
         var s = [];
         e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame ||   > e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
             setTimeout(e, 1e3 / 60)
          }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform:   rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform:    > rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background:   inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position:   fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
     }(window, document);

    </script>
最后修改:2019 年 09 月 21 日 06 : 15 PM
如果觉得我的文章对你有用,请随意赞赏

发表评论