首页 > 其他分享 >如何创建&美化博客

如何创建&美化博客

时间:2022-12-25 11:00:25浏览次数:61  
标签:function heart 创建 美观 点击 博客 window 美化

如何创建&美化博客

注:本文所有代码,均来自网络。

1.创建博客

1.1注册:

首先要注册一个博客园的账号:博客园首页;在主页的右上角,点击注册,按照步骤填写即可。

1.2申请博客:

有了账号之后,将鼠标悬停在右上角的头像上,点击“我的博客”,会有申请开通博客的页面,申请需要管理员审核,至于申请理由,我已经为大家追备好了:

尊敬的管理员,您好,我想拥有一个属于自己的博客,用来写文章,供其他用户学习和参考,希望您能批注准,谢谢。

大约一两个小时,就可以通过了;这时候,再填写各种信息,就有了一个新的博客。

但是这个博客比较简陋,如果你想让自己的博客变得更美观,那就继续看接下来的操作。

2.美化博客

2.1:博客皮肤:

将鼠标悬停在右上角的头像上,点击“我的园子”,在右边一栏中,点击写博,就到了博客的后台;

在一横排的栏目中,点击“设置”,在下面找到“博客皮肤”,这里有多种皮肤供大家选择,可以使博客变得美观一些。

但是它还是不够美观,要想更美观,就继续看以下操作。

2.2申请JS权限:

想要更美观,就需要代码了,但在这之前,要申请JS权限(在博客皮肤的下方)。

JS权限同样需要审核,可以参考下面的理由:

尊敬的管理员,您好,我想使我的博客更加美观,需要申请JS权限,希望您能批注准,谢谢。

也用不了几分钟,就通过了。

2.3编写代码:

这个代码粘贴到“页面定制CSS代码”,千万不要忘了钩上“禁用模板默认CSS”。

下面是一个模板,将以下代码粘贴到博客侧边栏公告,按照格式填写信息。

<script type="text/javascript">
    window.cnblogsConfig = {
        GhVersions    : 'v1.3.2', 
        blogUser      : "用户名", 
        blogAvatar    :"用户头像网址",
        blogStartDate : "注册博客园的时间", 
    }
</script>
<script src="https://cdn.jsdelivr.net/gh/BNDong/[email protected]/src/script/simpleMemory.min.js"></script>
<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>

如果你想拥有鼠标吸引线条特效,那就将以下代码粘贴到博客侧边栏公告,在 color="0,200,255" 处,可以更改你喜欢颜色的色号。

<!--鼠标吸引线条特效-->
<script id="canvas_nest" defer="defer" color="0,200,255" opacity="0.7" zIndex="-1" count="150" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script>
<script>POWERMODE.colorful = true;POWERMODE.shake = true;POWERMODE.mobile = false;document.body.addEventListener('input', POWERMODE);</script>

最后,再返回到原来的地方,在“博客皮肤”里选择 SimpleMemory,点击保存,就完成了

3.效果展示

效果展示

标签:function,heart,创建,美观,点击,博客,window,美化
From: https://www.cnblogs.com/zzyblog0619/p/17003770.html

相关文章