主頁美化:
主要參考嘻哈燒餅的美化,在他的基礎上增加了對主頁背景、色調以及側邊欄的調整
原帖地址: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="http://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>
待完成的美化:
導航欄自動分類、增強分享等,待部落格內容更豐富時再嘗試。