個人博客轉移至:https://sunhwee.com,第一時間會先發在前者,有時間再更新至博客園。
閱讀目錄:
1. 前言
2. 定制自己的博客
-
-
- 00. 美化整體效果
- 01. 准備工作
- 02. 自定義個性化導航欄
- 03. 添加頂部博主信息
- 04. 添加頂部滾動公告
- 05. 為博客文章添加目錄導航
- 06. 添加分享功能按鍵
- 07. 定制推薦和反對按鍵的炫酷樣式
- 08. 添加快速返回頂部的功能按鍵
- 09. 添加打賞功能按鍵
- 10. 添加頁面放大縮小功能按鍵
- 11. 添加Github圖標及鏈接
- 12. 添加公告欄圖片
- 13. 添加公告欄文字信息
- 14. 添加公告欄個性時鍾
- 15. 為公告欄添加訪客來源統計
- 16. 為公告添加訪客總數統計
- 17. 定制左側隨筆分類上下項之間的間距
- 18. 定制博客背景圖片
- 19. 鼠標點擊心形特效
- 20. 設置個性化簽名格式
-
3. 后語
一. 前言
要說個人技術博客網站,有很多,像CSDN、博客園、簡書、知乎專欄、Github Page等等,應該來說各有優缺點吧,這幾個博客我也用過,個人來說還是比較喜歡博客園這種多一點,簡單純凈,廣告比較少,不影響整體觀感,不過確實有些頁面是有些顯得老舊了。好在博客園支持用戶自己定制自己的博客頁面。這也是我認為博客園最大的優點和成功:允許你對自己的博客進行各種操作。其他博客像CSDN這種,一般好多都會限制你使用HTML標簽。
一般官方提供你的一些博客主題皮膚模板選項,有很多風格你可能不一定喜歡,剛開始,想自己定制,可能感覺又無從下手。好在圈里還是有很多大佬善於分享,有很多相關的博客園美化教程的。不過,相對比較零散,找起來麻煩,我也看了不少,然后把相關美化定制代碼看懂,接着改成自己喜歡的布局和風格,為了各位小伙伴能夠自己定制自己的個人博客,美化博客園博客界面,這里我也做一個分享,也相當於對網上各種教程做一個整理綜合。
強調一下:當然,每個人喜歡的風格不一定相同,只是我用這個皮膚定制的主頁,我覺得簡單明了,方便管理,強調實用性,如果你是文藝青年,也可以選擇其他皮膚或博客網站或者自己建站,來設計制作比較文藝美觀的界面。
我用的官方模板是預覽圖片選擇皮膚的第一個:AnotherEon001,講道理,其他皮膚模板,下面的定制代碼也是可以用的,只不過你需要做一些修改,比如位置,大小,顏色,布局搭配等。你要什么樣子,就改成什么。
好勒,廢話不多說了,咱們開始吧!
二. 定制自己的博客
以下內容代碼比較多,所以代碼全部默認折疊,你需要點開代碼塊加號看。
0. 美化整體效果
定制之前先來看看定制的整體效果。
我用的官方模板是預覽圖片選擇皮膚的第一個:AnotherEon001,如果你要想達到和我博客主頁一樣的效果,推薦用這個模板皮膚來改。當然,每個人喜歡的風格不一定相同,只是我用這個皮膚定制的主頁,我覺得簡單明了,方便管理,強調實用性,如果你是文藝青年,也可以選擇其他皮膚,來定制比較文藝界面。
講道理,其他皮膚模板,下面的定制代碼也是可以用的,只不過你需要做一些修改,比如位置,大小,顏色,布局搭配等。你要什么樣子,就改成什么。
1. 准備工作
首先,你要定制,得先獲取網站的的JS(JavaScript)權限,很多教程都忘記提這一點了,其實這點很關鍵。你看到別人的定制效果很好,然后把代碼粘到自己博客,發現怎么不生效?可能就是你沒獲得定制JS權限。那么在那里獲得這個權限呢?接下來,你要在你的博客主頁點擊“管理”---->點擊“設置”----下翻找到“申請JS權限”(我已經獲取權限了,所以顯示的“支持JS代碼”)
好了,做完這三步,你需要等一等權限審核通過,白天申請應該很快就通過了,如果時間比較長還沒通過,你可以給博客園后台發給郵件去申請,發給contact@cnblogs.com 有了權限你就可以開始下面的定制了
2. 自定義個性化導航欄
首先,我們要屏蔽官方模板自帶導航欄,然后才能把自己寫好的導航欄加上去,這個導航欄內容你可以自己修改成你自己的,按注釋提示,用編輯器修改好代碼,然后把它分別粘貼到“頁面定制CSS代碼”框和“頁首Html代碼”框,代碼如下(代碼默認折疊,你需要點開加號看):
頁面定制CSS代碼:

#header{display:none;} /* 將默認的導航頭屏蔽掉,這樣才能把自己的導航欄加上去 */ /* 定制自己導航欄的樣式 */ #shwtop ul { margin: 0; padding: 0; list-style-type: none; /*去除li前的標注*/ background-color: #333; overflow: hidden; /*隱藏溢出的部分,保持一行*/ } #shwtop li { float: left; /*左浮動*/ } #shwtop li a, .dropbtn { display: inline-block; /*設置成塊*/ color: white; text-align: center; text-decoration: none; padding: 14px 16px; } /*鼠標移上去,改變背景顏色*/ #shwtop li a:hover, .dropdown:hover .dropbtn { /* 當然顏色你可以自己改成自己喜歡的,我還是挺喜歡藍色的 */ background-color: blue; } #shwtop .dropdown { /* display:inline-block將對象呈遞為內聯對象, 但是對象的內容作為塊對象呈遞。 旁邊的內聯對象會被呈遞在同一行內,允許空格。 */ display: inline-block; } #shwtop .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); } #shwtop .dropdown-content a { display: block; color: black; padding: 8px 10px; text-decoration:none; } #shwtop .dropdown-content a:hover { background-color: #a1a1a1; } #shwtop .dropdown:hover .dropdown-content{ display: block; }

<!-- 創建新的導航欄,內容可更改為你自己的--> <div id="shwtop" > <ul style="margin-left:0px;margin-right: 0px;" class="test11" > <div class="dropdown"> <a href="https://www.cnblogs.com/" class="dropbtn">博客園首頁</span></a> <div class="dropdown-content"> </div> </div> <div class="dropdown"> <a href="http://www.cnblogs.com/shwee/" class="dropbtn">我的首頁</span></a> <div class="dropdown-content"> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">全部分類</a> <div class="dropdown-content"> <!-- <a class="menu" href="這里是你文章或隨筆分類的鏈接地址,自己修改下面同理"> 這里更改下拉具體內容 </a> --> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217679.html" >1.Linux基礎</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1211712.html" >2.Python基礎</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217691.html" >3.Python進階</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217693.html" >4.項目實戰</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" >5.人工智能</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" >6.閱讀筆記</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">Linux基礎</a> <div class="dropdown-content"> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217679.html" >1.基礎知識</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217679.html" >2.Linux發行版本</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217679.html" >3.Linux命令行操作</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">Python基礎</a> <div class="dropdown-content"> <a class="menu" href="http://www.cnblogs.com/shwee/category/1211712.html" target="_Blank">1.認識Python</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1211712.html" target="_Blank">更多...</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">Python進階</a> <div class="dropdown-content"> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217691.html" target="_Blank">1.面向對象</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217691.html" target="_Blank">2.網絡編程</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217691.html" target="_Blank">更多...</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">項目實戰</a> <div class="dropdown-content"> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217693.html" target="_Blank">1.這部分后續更新</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217693.html" target="_Blank">更多...</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">人工智能</a> <div class="dropdown-content"> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" target="_Blank">1.機器學習</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" target="_Blank">2.深度學習</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" target="_Blank">3.計算機視覺</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" target="_Blank">4.自然語言處理</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" target="_Blank">5.圖像處理</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1217695.html" target="_Blank">更多...</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">閱讀人生</a> <div class="dropdown-content"> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" target="_Blank">1.學術著作</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" target="_Blank">2.詩詞歌賦</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" target="_Blank">3.閑書雜文</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" target="_Blank">4.報刊新聞</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" target="_Blank">5.電影小說</a> <a class="menu" href="http://www.cnblogs.com/shwee/category/1212750.html" target="_Blank">更多...</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">學習資源</a> <div class="dropdown-content"> <a class="menu" href="https://docs.djangoproject.com/en/2.0/" target="_Blank">1.Django2.0官網</a> <a class="menu" href="http://docs.jinkan.org/docs/flask/" target="_Blank">2.Flask文檔</a> <a class="menu" href="http://www.runoob.com/bootstrap/bootstrap-tutorial.html" target="_Blank">3.Bootstrap教程</a> <a class="menu" href="http://www.django-rest-framework.org/" target="_Blank">4.REST framework官網</a> </div> </div> <div class="dropdown"> <a href="#" class="dropbtn">娛樂休閑</a> <div class="dropdown-content"> <a class="menu" href="http://music.163.com/" target="_Blank">1.雲音樂</a> <a class="menu" href="http://music.163.com/" target="_Blank">2.QQ音樂</a> <a class="menu" href="https://www.bilibili.com/" target="_Blank">3.bilibili</a> <a class="menu" href="http://yingyu.xdf.cn/list_907_1.html" target="_Blank">4.雙語閱讀</a> <a class="menu" href="http://720yun.com/" target="_Blank">5.全景圖片欣賞</a> <a class="menu" href="https://weibo.com/" target="_Blank">6.微博</a> <a class="menu" href="http://china.nba.com/" target="_Blank">7.NBA</a> <a class="menu" href="https://www.toutiao.com/" target="_Blank">8.今日頭條</a> <a class="menu" href="https://tieba.baidu.com/f?kw=%C4%DA%BA%AD%B6%CE%D7%D3&fr=ala0&tpl=5" target="_Blank">9.內涵段子</a> </div> </div> </ul> </div>
效果如下:
3. 添加頂部博主信息
為博客主頁添加頂部信息,方便別人快速識別博主,代碼放在“頁首Html代碼”中,你也可以修改字體樣式,頂部信息框的高度等,代碼如下:
頁首Html代碼:

<!-- 添加博客頂部博主信息--> <p style="text-align: center;font-size:35px;margin-bottom:5px;margin-top:20px;opacity: 0.5">歡迎來到洪衛的博客</p>
效果如下:
4. 添加頂部滾動公告
添加頂部滾動公告,你可以隨時修改內容,快速告訴訪問者你想分享的信息,比如一些好玩的事情,你的聯系方式,或者什么通知。同樣的,樣式可以自己修改,代碼如下:
頁首Html代碼:

<!-- 添加頂部滾動信息(公告)例子:《沁園春.雪》--> <div id="Scroll_info" style="text-align: center;color:red;font-size:13px;padding:5px;opacity: 0.5">人生三從境界:昨夜西風凋碧樹,獨上高樓,望盡天涯路。 衣帶漸寬終不悔,為伊消得人憔悴。 眾里尋他千百度,驀然回首,那人卻在燈火闌珊處。</div> <script> function func(){ var tag = document.getElementById('Scroll_info'); var content = tag.innerText; var f = content.charAt(0); var l = content.substring(1,content.length); var new_content = l + f; tag.innerText = new_content; } setInterval('func()',1600); </script>
效果如下:
5. 為博客文章添加目錄導航
為博客文章添加一個目錄導航,可以自動讀取顯示你當前文章的目錄,方便文章閱讀,目錄為兩級,為H2、H3,也就是默認編輯器的標題2和標題3格式,Markdown對應##和###,所以只要你以后文章按照這個標題格式寫,就能自動生成目錄,當然你可以修改代碼實現三級目錄,你可以試試。目錄導航按鍵的位置,大小,顏色等樣式你可以修改代碼改變,把代碼放到“頁面定制CSS代碼”框和“頁首Html代碼”框,代碼如下:
頁面定制CSS代碼:

/* 定制生成博客目錄的CSS樣式 */ #uprightsideBar{ font-size:16px; font-family:Arial, Helvetica, sans-serif; text-align:left; position:fixed; /* 將div的位置固定到距離top:150px,right:0px的位置, 這樣div就會處在最右邊的位置,距離頂部150px, 當然這兩個值你可以自己改。 */ top:150px; right:0px; width: auto; height: auto; } #sideBarTab{ float:left; width:25px; box-shadow: 0 0 8px #877788; border:1px solid #00DDC00; border-right:none; text-align:center; background:rgb(0, 220, 0); } #sideBarContents{ float:left; overflow:auto; overflow-x:hidden;!important; width:200px; min-height:101px; max-height:460px; border:1px solid #e5e5e5; border-right:none; background:#ffffff; } #sideBarContents dl{ margin:0; padding:0; } #sideBarContents dt{ margin-top:5px; margin-left:5px; } #sideBarContents dd, dt { cursor: pointer; } #sideBarContents dd:hover, dt:hover { color:#A7995A; } #sideBarContents dd{ margin-left:20px; }
頁腳Html代碼:

<!-- 生成博客目錄的JS代碼,兩級目錄 --> <script type="text/javascript"> /* 這段代碼按H2、H3格式生成兩級菜單 寫博客按H2、H3格式寫,不然生成不了 Markdown寫作按##、###兩級目錄寫 當然你也可以改寫代碼成三級菜單 參考:孤傲蒼狼 zhang_derek 洪衛 2018-5-18 */ var BlogDirectory = { /* 獲取元素位置,距瀏覽器左邊界的距離(left)和距瀏覽器上邊界的距離(top)*/ getElementPosition:function (ele) { var topPosition = 0; var leftPosition = 0; while (ele){ topPosition += ele.offsetTop; leftPosition += ele.offsetLeft; ele = ele.offsetParent; } return {top:topPosition, left:leftPosition}; }, /*獲取滾動條當前位置 */ getScrollBarPosition:function () { var scrollBarPosition = document.body.scrollTop || document.documentElement.scrollTop; return scrollBarPosition; }, /* 移動滾動條,finalPos 為目的位置,internal 為移動速度 */ moveScrollBar:function(finalpos, interval) { //若不支持此方法,則退出 if(!window.scrollTo) { return false; } //窗體滾動時,禁用鼠標滾輪 window.onmousewheel = function(){ return false; }; //清除計時 if (document.body.movement) { clearTimeout(document.body.movement); } //獲取滾動條當前位置 var currentpos =BlogDirectory.getScrollBarPosition(); var dist = 0; //到達預定位置,則解禁鼠標滾輪,並退出 if (currentpos == finalpos) { window.onmousewheel = function(){ return true; } return true; } //未到達,則計算下一步所要移動的距離 if (currentpos < finalpos) { dist = Math.ceil((finalpos - currentpos)/10); currentpos += dist; } if (currentpos > finalpos) { dist = Math.ceil((currentpos - finalpos)/10); currentpos -= dist; } var scrTop = BlogDirectory.getScrollBarPosition();//獲取滾動條當前位置 window.scrollTo(0, currentpos);//移動窗口 if(BlogDirectory.getScrollBarPosition() == scrTop)//若已到底部,則解禁鼠標滾輪,並退出 { window.onmousewheel = function(){ return true; } return true; } //進行下一步移動 var repeat = "BlogDirectory.moveScrollBar(" + finalpos + "," + interval + ")"; document.body.movement = setTimeout(repeat, interval); }, htmlDecode:function (text){ var temp = document.createElement("div"); temp.innerHTML = text; var output = temp.innerText || temp.textContent; temp = null; return output; }, /* 創建博客目錄,id表示包含博文正文的 div 容器的 id, mt 和 st 分別表示主標題和次級標題的標簽名稱(如 H2、H3,大寫或小寫都可以!), interval 表示移動的速度 */ createBlogDirectory:function (id, mt, st, interval){ //獲取博文正文div容器 var elem = document.getElementById(id); if(!elem) return false; //獲取div中所有元素結點 var nodes = elem.getElementsByTagName("*"); //創建博客目錄的div容器 var divSideBar = document.createElement('DIV'); divSideBar.className = 'uprightsideBar'; divSideBar.setAttribute('id', 'uprightsideBar'); var divSideBarTab = document.createElement('DIV'); divSideBarTab.setAttribute('id', 'sideBarTab'); divSideBar.appendChild(divSideBarTab); var h2 = document.createElement('H2'); divSideBarTab.appendChild(h2); var txt = document.createTextNode('目錄導航'); h2.appendChild(txt); var divSideBarContents = document.createElement('DIV'); divSideBarContents.style.display = 'none'; divSideBarContents.setAttribute('id', 'sideBarContents'); divSideBar.appendChild(divSideBarContents); //創建自定義列表 var dlist = document.createElement("dl"); divSideBarContents.appendChild(dlist); var num = 0;//統計找到的mt和st mt = mt.toUpperCase();//轉化成大寫 st = st.toUpperCase();//轉化成大寫 //遍歷所有元素結點 for(var i=0; i<nodes.length; i++) { if(nodes[i].nodeName == mt|| nodes[i].nodeName == st) { //獲取標題文本 var nodetext = nodes[i].innerHTML.replace(/<\/?[^>]+>/g,"");//innerHTML里面的內容可能有HTML標簽,所以用正則表達式去除HTML的標簽 nodetext = nodetext.replace(/ /ig, "");//替換掉所有的 nodetext = BlogDirectory.htmlDecode(nodetext); //插入錨 nodes[i].setAttribute("id", "blogTitle" + num); var item; switch(nodes[i].nodeName) { case mt: //若為主標題 item = document.createElement("dt"); break; case st: //若為子標題 item = document.createElement("dd"); break; } //創建錨鏈接 var itemtext = document.createTextNode(nodetext); item.appendChild(itemtext); item.setAttribute("name", num); //添加鼠標點擊觸發函數 item.onclick = function(){ var pos = BlogDirectory.getElementPosition(document.getElementById("blogTitle" + this.getAttribute("name"))); if(!BlogDirectory.moveScrollBar(pos.top, interval)) return false; }; //將自定義表項加入自定義列表中 dlist.appendChild(item); num++; } } if(num == 0) return false; /* 鼠標進入時的事件處理 */ divSideBarTab.onmouseenter = function(){ divSideBarContents.style.display = 'block'; } /* 鼠標離開時的事件處理 */ divSideBar.onmouseleave = function() { divSideBarContents.style.display = 'none'; } document.body.appendChild(divSideBar); } }; window.onload=function(){ /* 頁面加載完成之后生成博客目錄 */ BlogDirectory.createBlogDirectory("cnblogs_post_body","h2","h3",20); //為右下角推薦推薦區域添加關注按鈕 $('#div_digg').prepend('<div style="padding-bottom: 5px"><span class="icon_favorite" style="padding-top: 2px"></span><a onclick="cnblogs.UserManager.FollowBlogger(\'9a35f2c7-18ab-e111-aa3f-842b2b196315\');" href="javascript:void(0);" style="font-weight: bold; padding-left:5px;">關注一下樓主吧</a> </div>'); } </script>
效果如下:
![]() |
![]() |
![]() |
6. 添加分享功能按鍵
添加分享功能按鍵,方便自己或讀者快速分享內容到各個社區網站,把代碼放到“頁首Html代碼”框,當然你可以修改參數調整按鍵的位置,使界面布局好看些,代碼如下:
頁首Html代碼:

<!-- 為頁面添加分享功能按鍵 --> <script> window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"6","bdPos":"right","bdTop":"340"},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)]; </script>
效果如下:
![]() |
![]() |
7. 定制推薦和反對按鍵的炫酷樣式
定制推薦和反對按鍵的炫酷樣式,讓其在文章內容頁面浮在頁面右下角,方便讀者推薦和嫌棄,按鍵的樣式和位置你可以修改代碼來調整,代碼如下:
頁面定制CSS代碼:

/* 定制推薦和反對按鍵 */ #div_digg{ position:fixed; bottom:-10px; width:120px; right:20px; box-shadow: 0 0 6px #0000FF; border:2px solid #FF0000; padding:4px; background-color:#fff; border-radius:4px 4px 4px 4px !important; } .icon_favorite { background: transparent url('http://images.cnblogs.com/cnblogs_com/shwee/1218109/o_kj.gif') no-repeat 0 0; padding-left: 15px; } #blog_post_info_block a { text-decoration: none; color: #5B9DCA; padding: 3px; }
效果如下:
8. 添加快速返回頂部的功能按鍵
添加快速返回頂部的功能按鍵,使其能夠在文章任意文字快速返回文章頂部,把代碼分別粘貼到“頁面定制CSS代碼”框和“頁首Html代碼”框,和上面一樣修改代碼,可以調整按鍵的位置,大小等,代碼如下:
頁面定制CSS代碼:

/* 定制返回頂部按鍵 */ #toTop { background: url(//http://images.cnblogs.com/cnblogs_com/shwee/1218109/o_toTop.bmp) no-repeat 0px top; width: 57px; height: 57px; overflow: hidden; position: fixed; right: 180px; bottom: 20px; cursor: pointer; }
頁首Html代碼:

<!-- 指定返回頂部位置#shwtop --> <a href="#shwtop"><div id="toTop" style="zoom:0;"></div></a>
效果如下:
9. 添加打賞功能按鍵
為博客添加一個打賞功能按鍵,如果讀者覺得你的文章對他有幫助,他可以通過這個按鍵來打賞你。當然,要用這個插件功能,首先你得配置以下參數。代碼list[]q里面rImg: 'https://files.cnblogs.com/files/shwee/alipay.bmp'市里的支付寶或者微信二維碼的圖片位置,你要修改成你自己的。
你需要先到支付寶或者微信客戶端生成一個二維碼,然后保存到手機,上傳到電腦,再上傳到你的博客相冊中,然后獲得圖片源鏈接。當然你可先修改一下二維碼圖片的大小,這個用Windows自帶的畫圖功能就能改,很方便。后面我們需要的公告欄頭像,背景圖片這些,大小格式都可以用Windows的畫圖軟件快速修改,如下圖:
支付寶和微信等的二維碼鏈接修改好了之后,你修改top: '60%' 這一項可以改變按鍵的在屏幕的位置,調到你屏幕的合適位置,這里可以用百分比%,也可以用像素px來指定,id:9這一項修改顏色,1~9代表不同的9種顏色,你可以試試修改,type:'dashang'這一項是修改顯示文字的,有兩種顯示,一種是打賞(dashang),一種是贊助(zanzhu),這個插件的作者把代碼提供在github,你可以去fork一下,然后可以修改提交你自己的PR。好了,代碼如下:
頁首Html代碼:

<!-- 添加打賞功能按鍵 --> <script src="http://static.tctip.com/tctip-1.0.0.min.js"></script> <script> new tctip({ top: '60%', button: { id: 9, type: 'dashang', }, list: [ { type: 'alipay', qrImg: 'https://files.cnblogs.com/files/shwee/alipay.bmp' }, { type: 'wechat', qrImg: 'https://files.cnblogs.com/files/shwee/wechat.bmp' } ] }).init() </script>
效果如下:
![]() |
![]() |
10. 添加頁面放大縮小功能按鍵
添加頁面擴大縮小功能按鍵,點擊放大,左側邊欄顯示,閱讀界面擴大,點擊縮小恢復,修改代碼參數,適用於其他皮膚模板。把代碼分別粘貼到“頁面定制CSS代碼”框和“頁首Html代碼”框,修改代碼參數,可以調整按鍵的位置、大小、顏色和透明度這些信息。代碼如下:
頁面定制CSS代碼:

/* 定制頁面擴大按鍵 */ #divExpandViewArea{ position: fixed; color: white; padding: 10px 10px; left: 0px; top: 400px; cursor: pointer; opacity: 0.9; background-color: #68228B; } /* 定制頁面縮小按鍵 */ #divCollapseViewArea{ position: fixed; color: white; padding: 10px 10px; left: 0px; top: 445px; cursor: pointer; opacity: 0.9; background-color: #68228B; }
頁首Html代碼:

<!-- 添加頁面放大和縮小功能按鍵 --> <div id="divExpandViewArea" onclick="$('#main_container').css({'margin-left':'-195px'});$('#leftmenu').css({'display':'none'});">擴大</div> <div id="divCollapseViewArea" onclick="$('#main_container').css({'margin-left':'0px'});$('#leftmenu').css({'display':'block'});">縮小</div>
效果如下圖的圈4顯示:
![]() |
![]() |
11. 添加Github圖標及鏈接
為博客頁面添加Github圖標,點擊圖標快速鏈接到你的github或者其他網址。當然,你可以修改圖標的樣式,把代碼放在“頁首Html代碼”框中,代碼如下:
頁首Html代碼:

<!-- 博客頁面腳添加Github鏈接或其他鏈接 --> <!-- 頁面左上角 --> <a href="https://shw2018.github.io/" title="我的站點" target="_Blank" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; left: 0; transform: scale(-1, 1);" 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> <!-- 頁面右上角 --> <a href="https://github.com/shw2018" 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>
效果如下:
12. 添加公告欄圖片
添加公告欄圖片,當然你可以添加自己的頭像信息,公告欄的添加代碼要注意順序,添加的項目顯示順序是從上到下的,把代碼放到“博客側邊欄公告(支持HTML代碼)(支持JS代碼)”。前面已經提到了,放進來的圖片一定要注意尺寸大小,不然顯示不完,或者顯示太小,同樣的道理可以用Windows自帶的畫圖工具來修改尺寸(按像素尺寸改),這個看我前面 第9項 所寫。你需要吧代碼里面的鏈接和圖片鏈接改為你自己的,代碼如下:
博客側邊欄公告代碼:

<!-- 添加公告欄圖片並指向首頁鏈接 --> <div align="center"> <a href="http://www.cnblogs.com/shwee/"> <img src="http://images.cnblogs.com/cnblogs_com/shwee/1218109/o_head_pic_190x217.png"></a> </div>
效果如下圖圈 1 表示:
13. 添加公告欄文字信息
添加博客公告欄文字信息,這里可以放置你想讓其他人快速看到額文字信息,也可以背后加上鏈接,方便快速跳轉。可以修改文字大小,顏色,位置信息,代碼如下:
博客側邊欄公告代碼:

<p class="gonggao"><a style="color: blue;font-weight: bold;" href="http://www.cnblogs.com/shwee/p/9056959.html">我的博客目錄結構</a></p> <p class="wenzi">一個不像技術博客的博客</p> <p>-------------------------------</p>
頁面定制CSS代碼:

/* 定制公告欄文字信息 */ .gonggao{ text-align: center; font-size:17px; color:blue; } .wenzi{ text-align: center; font-size:15px; }
效果如上圖 圈 2 表示:
14. 添加公告欄個性時鍾
添加博客公告欄個性時鍾,代碼如下:
博客側邊欄公告代碼:

<!-- 添加公告欄時鍾 --> <div id="clockdiv"> <canvas id="dom" width="120" height="120">時鍾canvas</canvas> </div> <script type="text/javascript" src="https://files.cnblogs.com/files/shwee/clock.js"></script>
頁面定制CSS代碼:

/* 定制公告欄時鍾位置 */ #clockdiv { /* left, center, right */ text-align: center; }
效果如第12項圖片 圈 3 表示:
15. 為公告欄添加訪客來源統計
為公告欄添加訪客來源統計,需要用到Flag Counter這個插件,網址:http://s11.flagcounter.com/more/Fe64/ 你可以去官網注冊一個,獲取個免費版,然后設置信息參數,像我下圖這樣,統計插件背景顏色設置為側邊欄的顏色,這樣看上去就是一體的,我的側邊欄顏色是#EEEEEE,用畫圖工具的顏色拾取器拾取的。設置完參數后復制代碼,項下圖2箭頭所指,然后粘貼到側邊公告欄代碼框中,注意粘貼位置順序,上面已經說了。這個代碼每個人不太一樣,所以就不貼代碼了。
![]() |
![]() |
效果如下圖 圈 5 表示:
16. 為公告添加訪客總數統計
添加博客公告欄訪客總數統計,和15一樣這是個三方插件,你可以去注冊一個賬號,免費是設置一個,網址:http://www.amazingcounters.com/ 然后復制配置好的代碼,復制粘貼到博客側邊公告欄代碼框里面,代碼因人而異,就不貼具體代碼了。
效果如第15項圖片 圈 6 表示:
17. 定制左側隨筆分類上下項之間的間距
定制左側隨筆分類上下項之間的間距,左側隨筆分類顯示有多少項,你就在后面增加多少項,代碼如下:
頁面定制CSS代碼:

/* 定制左側隨筆分類上下項之間的間距,左側隨筆分類顯示有多少項,你就在后面增加多少項 */ #CatList_LinkList_0_Link_0{ } #CatList_LinkList_0_Link_1{ margin-top:10px; } #CatList_LinkList_0_Link_2{ margin-top:10px; } #CatList_LinkList_0_Link_3{ margin-top:10px; } #CatList_LinkList_0_Link_4{ margin-top:10px; } #CatList_LinkList_0_Link_5{ margin-top:10px; } #CatList_LinkList_0_Link_6{ margin-top:10px; } #CatList_LinkList_0_Link_7{ margin-top:10px; } #CatList_LinkList_0_Link_8{ margin-top:10px; } #CatList_LinkList_0_Link_9{ margin-top:10px; } #CatList_LinkList_0_Link_10{ margin-top:10px; } #CatList_LinkList_0_Link_11{ margin-top:10px; } #CatList_LinkList_0_Link_12{ margin-top:10px; } #CatList_LinkList_0_Link_13{ margin-top:10px; } #CatList_LinkList_0_Link_14{ margin-top:10px; }
效果如下:
18. 定制博客背景圖片
定制博客背景圖片,url里面是你的圖片位置信息,代碼放在“頁面定制CSS代碼”框中
頁面定制CSS代碼:

/* 定制博客背景圖片,url里面是你的圖片位置信息 */ body { background-color: #efefef; background-image:url(http://images.cnblogs.com/cnblogs_com/shwee/1218109/o_bg_shw.jpg); background-repeat: no-repeat; background-attachment: fixed; background-position: center 0; background-size: cover; padding-top:0px; }
效果如下:
19. 鼠標點擊心形特效
為頁面添加鼠標點擊心形特效,代碼放在“
博客側邊欄公告代碼:

<!-- 為頁面添加愛心特效 --> <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>
效果如下:
20. 設置個性化簽名格式
設置個性化簽名格式,修改成自己喜歡的內容,使我們的簽名與眾不同,把代碼貼在“
頁面定制CSS代碼:

/* 設置簽名格式 定制css樣式 */ #MySignature { display: none; background-color: #B2E866; border-radius: 10px; box-shadow: 1px 1px 1px #6B6B6B; padding: 10px; line-height: 1.5; text-shadow: 1px 1px 1px #FFF; font-size: 16px; font-family: 'Microsoft Yahei'; }
設置簽名格式后,你需要去添加自己的簽名,在“管理”里面----->博客簽名,當然你要按照格式寫,比如:

<div>作者:<a href="http://www.cnblogs.com/shwee/">洪衛</a></div> <div>出處:<a href="http://www.cnblogs.com/shwee/">http://www.cnblogs.com/shwee/ </a></div> <p>-------------------------------------------</p> <p>個性簽名:獨學而無友,則孤陋而寡聞。做一個靈魂有趣的人!</p> <p>如果覺得這篇文章對你有小小的幫助的話,記得在右下角點個<span>“推薦”</span>哦,博主在此感謝!</p> <p></p> <p>萬水千山總是情,打賞一分行不行,所以如果你心情還比較高興,也是可以掃碼打賞博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!</p>
內容修改成你自己的就行
效果如下:
三. 后語
教程目前就到這里,以后有其他更新再添加。當然這篇項目比較多,有點長,有的功能項你不一定需要,所以你可以挑里面的東西添加到自己博客主頁,再說一下,要達到相同效果,推薦用 AnotherEon001 這個模板,雖然其他模板也可以,不過你需要修改不少代碼,無妨,你可以動手試一試。這一篇教程應該來說是為這方面沒啥基礎的寫的,如果你玩前端、網頁、設計這些玩得比較溜的,大可看看就行,哈哈哈!
再者,我之前看了一些這方面的隨筆,不過比較零散,當時忘記做個文章標簽了,所以沒法一一鏈上參考來源了,友情鏈接:http://www.cnblogs.com/derek1184405959/p/9018285.html。
哇,寫這個真是費時,花了我不少時間,所以當然希望能夠幫助到大家啦!
分享——使人快樂٩(๑❛ᴗ❛๑)۶!