欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-07-26 20:38:51
主页美化: 主要参考嘻哈烧饼的美化,在TA的基础上增加了对主页背景、色调以及侧边栏的调整 原帖地址:https://www.cnblogs.com/seanshao/p/5716543.html 修改博客园背景的代码如下(在原帖使用的css文件中修改): 修改主副标题颜色的代码如下(在原帖使用的cs ......

主页美化:

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

原帖地址:

修改博客园背景的代码如下(在原帖使用的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="http://files.cnblogs.com/files/keenster/bundle-simplememory-a5_v308.css"/>

 

细节美化:

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

原帖地址:

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

<!-- 爱心特效 -->
<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>

 

待完成的美化:

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