前言

Handsome主题
在复杂中,保持简洁。 一款精心打磨后的typecho主题

介绍

如果你是小白或者第一次使用这个模板,那一定要仔细看好了作者写的使用文档 本文博主整理了几种美化样式,希望有喜欢的~

美化

为了减少对源码的修改,本次美化大多数可以直接在后台开发者设置-自定义css中添加代码即可。

1. 头像呼吸光环和鼠标悬停旋转放大

    .img-full {
    width: 100px;
    border-radius: 50%;
    animation: light 4s ease-in-out infinite;
    transition: 0.5s;
}

.img-full:hover {
transform: scale(1.15) rotate(720deg);
}

@keyframes light {
    0% {
        box-shadow: 0 0 4px #f00;
    }

    25% {
    box-shadow: 0 0 16px #0f0;
    }

    50% {
    box-shadow: 0 0 4px #00f;
    }

    75% {
    box-shadow: 0 0 16px #0f0;
    }

    100% {
    box-shadow: 0 0 4px #f00;
    }
}

如果只需要单色呼吸光环,例如红色,可以将关键帧动画改为:

@keyframes light {
    from {
        box-shadow: 0 0 4px #f00;
    }

    to {
        box-shadow: 0 0 16px #f00;
    }
}

2. 左侧文章图标和评论头像鼠标悬停旋转

.img-circle {
    transition: all 0.3s;
}

.img-circle:hover {
    transform: rotate(360deg);
}

3. 文章内打赏图标跳动

.btn-pay {
    animation: star 0.5s ease-in-out infinite alternate;
}

@keyframes star {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

4. 彩色标签云

js为标签随机添加上预先定义的颜色,每次刷新都会进行换色:

let tags = document.querySelectorAll("#tag_cloud-2 a");
let colorArr = ["#428BCA", "#AEDCAE", "#ECA9A7", "#DA99FF", "#FFB380", "#D9B999"];
tags.forEach(tag => {
tagsColor = colorArr[Math.floor(Math.random() * colorArr.length)];
tag.style.backgroundColor = tagsColor;
});

如果主题中启用了pjax,还需要将上面代码添加到pjax回调函数中

5. 首页文章列表悬停上浮

.blog-post .panel:not(article) {
transition: all 0.3s;
}

.blog-post .panel:not(article):hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 10px rgba(73, 90, 47, 0.47);
}

6. 首页文章列表头图悬停放大并将超出范围隐藏

.index-post-img {
    overflow: hidden;
}

.item-thumb {
    transition: all 0.3s;
}

.item-thumb:hover {
    transform: scale(1.1)
}

7. 文章内头图和文章图片悬停放大并将超出范围隐藏

.entry-thumbnail {
    overflow: hidden;
}

#post-content img {
    border-radius: 10px;
    transition: 0.5s;
}

#post-content img:hover {
    transform: scale(1.05);
}

8. 右侧列表导航栏图标颜色

.glyphicon-fire {
    color: #ff0000;
}

.nav-tabs-alt .glyphicon-comment {
    color: #495dc3;
}

.glyphicon-transfer {
    color: #0e5458;
}

9. 点击空白区域隐藏歌曲列表

主题中原来是必须重新点击耳机图标才能将歌曲列表隐藏,感觉有点累,而且此时再点击闲言碎语会将两个元素重叠。设置之后可以点击空白区域将歌曲列表隐藏,由于本文主旨是尽量不修改源码,所以实现的方式较为繁琐。先添加css:

.musicPlayerHiden {
    display: none;
}

然后添加js代码:

document.body.onclick = function () {
    document.querySelector(".skPlayer-list").classList.add("musicPlayerHiden");
}

document.querySelector(".skPlayer-list-switch").onclick = function (e) {
    document.querySelector(".skPlayer-list").classList.remove("musicPlayerHiden");
    document.querySelector(".skPlayer-list").onclick = function (e) {
        if (e && e.stopPropagation) {
            e.stopPropagation();
        } else {
            window.event.cancalBubble = true;
        }
    }

    if (e && e.stopPropagation) {
        e.stopPropagation();
    } else {
        window.event.cancalBubble = true;
    }
}

10.文章标题居中

.panel h2{
    text-align: center; 
}
.post-item-foot-icon{
    text-align: center;
}

11.首页左侧博主介绍

将以下代码添加至后台-外观-初级设置-博主的介绍。这段代码可添加至网站任意位置

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

12.底部版权

1:先去除/usr/themes/handsome/component/footer.php中原有版权信息,将注释<!--可以去除主题版权信息,最好保留版权信息或者添加主题信息到友链,谢谢你的理解-->之前的代码替换即可

<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php Content::outputCommentJS($this, $this->security); ?>
</div><!-- /content -->
  <footer id="footer" class="app-footer" role="footer">
    <div class="wrapper bg-light">
      <span class="pull-right hidden-xs text-ellipsis">
      <?php $this->options->BottomInfo(); ?>
      
      </span>
          <span class="text-ellipsis">&nbsp;<?php
            $this->options->BottomleftInfo(); ?></span>
    </div>
      <!--可以去除主题版权信息,最好保留版权信息或者添加主题信息到友链,谢谢你的理解-->

2:将以下代码添加至后台-开发者设置-博客底部右侧信息(左侧类似)。

<div class="github-badge">
<a rel="license" href="http://beian.miit.gov.cn/" target="_blank" title="京ICP备18051114号-1">
<span class="badge-subject">京ICP备</span><span class="badge-value bg-black">18051114号-1</span></a>
</div>
&nbsp;|&nbsp; <div class="github-badge">
<a rel="license" href="http://www.typecho.org" target="_blank" title="由Typecho强力驱动">
<span class="badge-subject">Powered</span><span class="badge-value bg-blue">Typecho</span></a>
</div>
&nbsp;|&nbsp; <div class="github-badge">
<a rel="license" href="https://www.ihewro.com/archives/489/" target="_blank" title="站点使用 handsome 主题,作者:友人C">
<span class="badge-subject">Theme</span><span class="badge-value bg-orange">Handsome</span></a>
</div>

3:将以下代码添加至后台-开发者设置-自定义CSS。

.github-badge {
    display: inline-block;
    border-radius: 4px;
    text-shadow: none;
    font-size: 12px;
    color: #fff;
    line-height: 15px;
    background-color: #ABBAC3;
  margin-bottom: 5px;
}
.github-badge .badge-subject {
    display: inline-block;
    background-color: #4D4D4D;
    padding: 4px 4px 4px 6px;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}
.github-badge .badge-value {
    display: inline-block;
    padding: 4px 6px 4px 4px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
.github-badge .bg-brightgreen {
    background-color: #4DC820 !important;
}
.github-badge .bg-orange {
    background-color: #FFA500 !important;
}
.github-badge .bg-blueviolet {
    background-color: #8833D7 !important;
}
.github-badge .bg-firebrick {
    background-color: #EE2C2C !important;
}
.github-badge .bg-blue {
    background-color: #007EC6 !important;
}
.github-badge .bg-lightgrey {
    background-color: #9F9F9F !important;
}
.github-badge .bg-grey, .github-badge .bg-gray {
    background-color: #555 !important;
}
.github-badge .bg-lightgrey, .github-badge .bg-lightgray {
    background-color: #9f9f9f !important;
}

12.文章页面添加百度收录查询

在主题 functions.php 文件最下方新增

/**
* 提示文章百度是否收录
*
*/
function baidu_record() {
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if(checkBaidu($url)==1)
{echo "百度已收录";
}
else
{echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" 
href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\">百度未收录</a>";}
}
function checkBaidu($url) {
$url = 'http://www.baidu.com/s?wd=' . urlencode($url);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$rs = curl_exec($curl);
curl_close($curl);
if (!strpos($rs, '没有找到')) { //没有找到说明已被百度收录
return 1;
} else {
return -1;
}
}

第二步:在主题 post.php 文件想显示的地方增加

<!--百度收录-->
<li class="meta-categories"><i class="glyphicon glyphicon-ok-circle" aria-hidden="true"></i> 
<span class="sr-only"><?php _me("百度收录") ?>:</span> <span class="meta-value"><?php echo 
baidu_record() ?></span></li>