handsome主题魔改

关于本主题的一些修改方法,整理下留作自己的备忘,也方便看到这篇文章的朋友。


一、博主介绍的闪字特效

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

<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>

2、在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;
}

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

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

三、首页样式自定义CSS

(以下代码放入后台主题设置--自定义CSS)

1、首页文章板式圆角化

#圆角大小可修改15px数值
/*首页文章版式圆角化*/.panel{
    border: none;
    border-radius: 15px;
}
.panel-small{
    border: none;
    border-radius: 15px;
}
.item-thumb{
    border-radius: 15px;  
}

2、首页文章头图焦点放大

 #放大的时间和大小自行修改以下数值
/*首页文章图片获取焦点放大*/
.item-thumb{
    cursor: pointer;  
    transition: all 0.6s;  
}
    .item-thumb:hover{
          transform: scale(1.05);  
}
.item-thumb-small{
    cursor: pointer;  
    transition: all 0.6s;
}
.item-thumb-small:hover{
    transform: scale(1.05);

3、首页头像放大并旋转

#转动快慢和头像大小自行修改数值
/*首页头像自动旋转*/
.thumb-lg{
    width:130px;
}
    .avatar{
        -webkit-transition: 0.4s;
        -webkit-transition: -webkit-transform 0.4s ease-out;
        transition: transform 0.4s ease-out;
        -moz-transition: -moz-transform 0.4s ease-out; 
}
.avatar:hover{
    transform: rotateZ(360deg);
    -webkit-transform: rotateZ(360deg);
    -moz-transform: rotateZ(360deg);
}
#aside-user span.avatar{
    animation-timing-function:cubic-bezier(0,0,.07,1)!important;
    border:0 solid
}
#aside-user span.avatar:hover{
    transform:rotate(360deg) scale(1.2);
    border-width:5px;
    animation:avatar .5s

4、首页头像自动旋转并放大

#旋转速度请修改3s数值
/*首页头像放大并自动旋转*/
.thumb-lg{
    width:130px;
}

@-webkit-keyframes rotation{
        from {
                -webkit-transform: rotate(0deg);
    }
    to {
            -webkit-transform: rotate(360deg);
    }
}
.img-full{
    -webkit-transform: rotate(360deg);
        animation: rotation 3s linear infinite;
            -moz-animation: rotation 3s linear infinite;
                -webkit-animation: rotation 3s linear infinite;
                    -o-animation: rotation 3s linear infinite;

}

5、文章标题居中

/*文章标题居中*/
.panel h2{
    text-align: center; 
}
    .post-item-foot-icon{
        text-align: center;
}

6、首页文章板式阴影化

#阴影颜色修改rgba后面的值
/*panel阴影*/
.panel{
   box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
       -moz-box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
}
       .panel:hover{
           box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
               -moz-box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
}
               .panel-small{
                   box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
                       -moz-box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
}
                       .panel-small:hover{
                           box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
                               -moz-box-shadow: 1px 1px 5px 5px rgba(255, 112, 173, 0.35);
}

如果也想使盒子四周也有阴影,加上以下代码

.app.container {
box-shadow: 0 0 30px rgba(255, 112, 173, 0.35);

7、自定义滚动条

/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar{
    width: 3px;
    height: 16px;
    background-color: rgba(255,255,255,0);
} 
/*定义滚动条轨道 内阴影+圆角*/
    ::-webkit-scrollbar-track{
        -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
        border-radius: 10px;
        background-color: rgba(255,255,255,0);
} 
/*定义滑块 内阴影+圆角*/
        ::-webkit-scrollbar-thumb{
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
            background-color: #555;

四、鼠标点击特效

(将下框中的代码放在主题的handsome/component/footer.php中</body>之前即可)

<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>

五、修改首页标题栏

(首先后台“设置外观” → “主题增强功能” → “增强功能开关” → 勾选“首页的标题栏下启用一言接口”。接着去除此处的标题显示,修改方法为将下框中的代码在主题的handsome/index.php中删除。)

<h1 class="m-n font-thin h3 text-black l-h"><?php $this->options->title(); ?></h1>

六、底部版权修改

增加建站天数及备案信息、修改原版权样式。
以我的底部样式为例,此项在主题的handsome/component/footer.php替换修改即可。
建站天数代码为<?php echo floor((time()-strtotime('2018-05-20'))/86400);?>,
其中2018-05-20请按此日期格式修改建站时间。
底部右侧的站点地图:1/2是我添加了插件sitemap和baidu_sitemap,此链接可删除或替换。
原模板文件中是这样的↓

<div class="wrapper b-t bg-light">  <span class="pull-right hidden-xs">
<?php $this->options->BottomInfo(); ?>
Powered by <a target="blank" href="http://www.typecho.org">Typecho</a>&nbsp;|&nbsp;Theme by <a target="blank" href="https://www.ihewro.com/archives/489/">handsome</a>
</span>
&copy;&nbsp;<?php echo date("Y");?> Copyright&nbsp;<?php $this->options->BottomleftInfo(); ?></div>

修改后的是这样的,请自行替换修改↓

<div class="wrapper b-t bg-light">
<span class="pull-right hidden-xs">
<?php $this->options->BottomInfo(); ?>
[&nbsp;&nbsp;驱动:<a href="http://www.typecho.org" target="blank">Typecho</a>&nbsp;|&nbsp;模板:<a href="https://www.ihewro.com/archives/489/" target="blank">友人C</a>&nbsp;|&nbsp;站点地图:<a href="/sitemap.xml" target="blank">1</a>&nbsp;\&nbsp;<a href="/baidu_sitemap.xml" target="blank">2</a>&nbsp;|&nbsp;备案:<a href="http://www.miibeian.gov.cn" target="blank">备案号</a>&nbsp;&nbsp;]      </span>
[&nbsp;&nbsp;本站已安全运行<?php echo floor((time()-strtotime('2018-05-20'))/86400);?>天<?php $this->options->BottomleftInfo(); ?>&nbsp;&nbsp;]    </div>

七、顶部导航天气

在headnav.php中添加如下代码

<!-- 天气 -->
<div id="tp-weather-widget" class="navbar-form navbar-form-sm navbar-left shift"></div>
<script>(function(T,h,i,n,k,P,a,g,e){g=function(){P=h.createElement(i);a=h.getElementsByTagName(i)
[0];P.src=k;P.charset="utf-
8";P.async=1;a.parentNode.insertBefore(P,a)};T["ThinkPageWeatherWidgetObject"]=n;T[n]||
(T[n]=function(){(T[n].q=T[n].q||[]).push(arguments)});T[n].l=+new Date();if(T.attachEvent)
{T.attachEvent("onload",g)}else{T.addEventListener("load",g,false)}}
(window,document,"script","tpwidget","//widget.seniverse.com/widget/chameleon.js"))</script>
<script>tpwidget("init", {
"flavor": "slim",
"location": "WX4FBXXFKE4F",
"geolocation": "enabled",
"language": "auto",
"unit": "c",
"theme": "black",
"container": "tp-weather-widget",
"bubble": "enabled",
"alarmType": "badge",
"color": "#00AFDB",
"uid": "UB7BEE62D3",
"hash": "3600ce1f732c2aa637f35517da5f7081"
});
tpwidget("show");</script>
<!-- 天气结束 -->

八、去掉头部博客名称

外观设置--开发者设置--自定义 JavaScript

document.querySelector("header.lter").remove();

以上文字转自433.io如有侵权,请联系我删除

Last modification:August 9th, 2018 at 08:58 am
If you think my article is useful to you, please feel free to appreciate

6 comments

  1. To22

    请指教下如何修改 文章页面的CSS 或者说 间距 字体 等等的。。。在handsome里。。

    1. xcsoft
      @To22

      好像在主题的assets/css文件夹中修改相关css添加相关字体,然后在主题后台自定义css中改下下就好了

  2. 小羊

    标签云中引用此 CSS 文件那个 href怎么写..⌇●﹏●⌇

    1. xcsoft
      @小羊

      对不起,我没有听懂,可以描述清晰点吗?

  3. 四三三

    侵权倒是没有,我也是去别人那扒的。。

    1. xcsoft
      @四三三

      嗯。。。

Leave a Comment