个人博客园样式、背景及细节美化过程

主页美化:

主要参考嘻哈烧饼的美化,在TA的基础上增加了对主页背景、色调以及侧边栏的调整

原帖地址:https://www.cnblogs.com/seanshao/p/5716543.html

修改博客园背景的代码如下(在原帖使用的css文件中修改):

body {
    color: #000;

    background:url(https://www.cnblogs.com/images/cnblogs_com/Keenster/1344881/o_169wallhaven-599106.jpg) fixed;
    background-position:center;
    background-size:cover;
    background-repeat: no-repeat;
    font-family: "微软雅黑" , "PTSans" , "Arial" ,sans-serif;
    font-size: 14px;
    min-height: 101%;
}

 修改主副标题颜色的代码如下(在原帖使用的css文件中修改):

/*主标题格式*/
    #blogTitle h1 {
        font-size: 26px;
        font-weight: bold;
        line-height: 1.8em;/*原始 1.6em*/
    }

        #blogTitle h1 a {
            color: #ffffff;
        }
            /*超链接颜色*/
            #blogTitle h1 a:hover {
                /*color: #21759b;*/
            }
    /*次标题格式*/
    #blogTitle h2 {
        font-weight: normal;
        font-size: 17px;/*原始 16px ;font-size: 1.0rem;*/      
        line-height: 1.8;
        color: #ffffff;
        float: left;
        white-space: nowrap;        
    }

 

修改侧边栏头像、图像居中,并添加超链接的代码如下:(在侧边栏公告中修改,而不是在css中修改)

<div   align="center">
<a href="https://github.com/qq849012418?tab=repositories" target="_blank"><img src="https://www.cnblogs.com/images/cnblogs_com/Keenster/1344729/o_17686334.png" alt="Keenster's Github" class="img_avatar" width="220px"></a>
</div>

 

至于返回顶部按钮,博文大小标题分类,直接使用了原帖的代码,就不一一列出了。

 

踩坑注意:css导入后要勾选“禁用默认css”否则会造成各种显示问题

我的css文件可以右键查看网页源代码获取(bundle-SimpleMemory-A5_v308.css),使用时基于SimpleMemory主题,懒得折腾的可以直接下载。

下载后,请上传到博客文件中,并按如下格式在页首html中添加代码:

<link type="text/css" rel="stylesheet" href="https://files.cnblogs.com/files/Keenster/bundle-SimpleMemory-A5_v308.css"/>

 

细节美化:

爱心特效、添加右上角github图标,主要参考Zhang_derek的美化

原帖地址:http://www.cnblogs.com/derek1184405959/p/9018285.html

鼠标点击时的爱心特效代码如下:(侧边栏中修改)

<!-- 爱心特效 -->
<script type="text/javascript">

(function(window,document,undefined){
        var hearts = [];
        window.requestAnimationFrame = (function(){
                return window.requestAnimationFrame || 
                           window.webkitRequestAnimationFrame ||
                           window.mozRequestAnimationFrame ||
                           window.oRequestAnimationFrame ||
                           window.msRequestAnimationFrame ||
                           function (callback){
                                   setTimeout(callback,1000/60);
                           }
        })();
        init();
        function init(){
                css(".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: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
                attachEvent();
                gameloop();
        }
        function gameloop(){
                for(var i=0;i<hearts.length;i++){
                    if(hearts[i].alpha <=0){
                            document.body.removeChild(hearts[i].el);
                            hearts.splice(i,1);
                            continue;
                    }
                    hearts[i].y--;
                    hearts[i].scale += 0.004;
                    hearts[i].alpha -= 0.013;
                    hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color;
            }
            requestAnimationFrame(gameloop);
        }
        function attachEvent(){
                var old = typeof window.onclick==="function" && window.onclick;
                window.onclick = function(event){
                        old && old();
                        createHeart(event);
                }
        }
        function createHeart(event){
            var d = document.createElement("div");
            d.className = "heart";
            hearts.push({
                    el : d,
                    x : event.clientX - 5,
                    y : event.clientY - 5,
                    scale : 1,
                    alpha : 1,
                    color : randomColor()
            });
            document.body.appendChild(d);
    }
    function css(css){
            var style = document.createElement("style");
                style.type="text/css";
                try{
                    style.appendChild(document.createTextNode(css));
                }catch(ex){
                    style.styleSheet.cssText = css;
                }
                document.getElementsByTagName('head')[0].appendChild(style);
    }
        function randomColor(){
                return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
        }
})(window,document);

</script>

 

添加github链接的代码如下:(在页首html中添加)

 

<a href="https://github.com/qq849012418?tab=repositories" title="我的github地址" target="_Blank" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#FD6C6C; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

 

待完成的美化:

导航栏自动分类、增强分享等,待博客内容更丰富时再尝试。

posted @ 2018-11-19 21:53  Keenster  阅读(1020)  评论(2编辑  收藏  举报