博客園美化筆記
阿新 • • 發佈:2018-12-16
源文件 ack 頁腳 切換 出現 tcs keyframes jquery pom
1.每日一言
P.S : 來自LOJ
在側邊欄加入以下css代碼即可
<meta charset="utf-8"/> <h2><B>一言(ヒトコト)</B></h2> <div class="daily a pome"> <div class="daily pome" id="qwq"></div> <script> var st=["<center>沒有神的光環,我們生而平凡 <br> <center>這就是你不拿rank1得理由?<br>", "<center>我遇見你,我記住你<br><center>這座城市天生適合戀愛,<br><center>你的靈魂天生適合我<br>", "<center>你知道<br><center>Nice to meet you<br><center>是什麽意思麽?<br><center>很高興見到你唄<br><center>不啊,“有生之年,幸得相逢。”<br>", "<center>前半生無你<br><center>余生請指教.<br>", "<center>你好,冒昧打攪了<br><center>我今天也特別喜歡你.<br>", "<center>it takes sonebody an hour to like someonoe,<br><center>and a day to like someone,<br><center>but it takes a life time to forget someone.<br>", "<center>you have only one life and one chance to do all the things you want to do.<br>", "<center>你就像桌上那份時事報,<br><center>當時讀新鮮,以後讀懷念<br><center>悲歡越來越遠,<br><center>可還是會小心翼翼地折好,安放<br>", "<center>你特別好,我喜歡你<br>", "<center>我終不能改變那個開始,<br><center>何不忘了那個結局呢?<br>", "<center>it takes only a smile to make a darkday seem bright<br>", "<center>無論在哪裏遇上你,<br><center>我都會喜歡你<br>", "<center> 你若盛開,清風自來<br>", "<center>用我一生,<br><center>換你十年天真。<br><center>忘了我吧,<br><center>吳邪。<br>", "<center>太想摘取星星得人,<br><center>往往忽視了腳下得鮮花。<br>", "<center> 無論發生什麽,<br><center>希望你都不要後悔與我得相識。<br>", "<center> 生生生生暗生始,<br><center>死死死死冥死終。<br>", "<center> 未來不是被給予的,<br><center>而是自己爭取的。 <br>", "<center> あたいってば最強ね! <br>", "<center> 十步殺一人,<br><center> 千裏不留行。<br>", "<center> 當一切都消失得時候<br><center> 你就會明白生命有何價值<br>", "<center> 不是他,變成他<br>", "<center> 也許我們都沒有長大,<br><center> 只是世界變小了。<br>", "<center> Time waits for no one.<br>", "<center> 和絕望,<br><center> 和睦相處<br>"]; var num; num=Math.floor((Math.random()*25)); document.write(st[num]); var cli; </script> <div style="font-size: 1em; text-align: center; line-height: 1.5em; display: none; " id="qwq"></div> <div style="text-align: right; margin-top: 15px; font-size: 0.9em; color: #666; display: none; " id="qwq"></div> </div>
2.鼠標點擊特效
大概效果可以自己試著點點
在頁腳html代碼處加入以下css代碼即可
<script type="text/javascript"> /* 鼠標特效 */ var a_idx = 0; jQuery(document).ready(function($) { $("body").click(function(e) { var a = new Array("?富強?","?民主?","?文明?","?和諧?","?自由?","?平等?","?公正?","?法治?","?愛國?","?敬業?","?誠信?","?友善?"); var $i = $("<span></span>").text(a[a_idx]); a_idx = (a_idx + 1) % a.length; var x = e.pageX, y = e.pageY; $i.css({ "z-index": 999999999999999999999999999999999999999999999999999999999999999999999, "top": y - 20, "left": x, "position": "absolute", "font-weight": "bold", "color": "rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")" }); $("body").append($i); $i.animate({ "top": y - 180, "opacity": 0 }, 1500, function() { $i.remove(); }); }); }); </script>
可以修改第六行中代碼中雙引號內的字
var a = new Array("?富強?","?民主?","?文明?","?和諧?","?自由?","?平等?","?公正?","?法治?","?愛國?","?敬業?","?誠信?","?友善?");
3.改變博客圖標
有沒有看到我與眾不同的博客圖標啊qwq?
要有這種效果也很簡單
在頁首html代碼處加入以下代碼即可
<div style = "display:none;" >把博客園圖標替換成自己的圖標 </div>
<script type="text/javascript" language="javascript">
//Setting ico for cnblogs
var linkObject = document.createElement('link');
linkObject.rel = "shortcut icon";
linkObject.href = "https://i.loli.net/2018/09/24/5ba8bcd213e78.jpg";
document.getElementsByTagName("head")[0].appendChild(linkObject);
</script>
<div style = "display:none;" >把博客園圖標替換成自己的圖標end </div>
將第六行的
linkObject.href = "https://i.loli.net/2018/09/24/5ba8bcd213e78.jpg";
其中的圖片地址換成自己的即可
(開頭和最後的註釋也可以刪掉,是我自己的習慣,下同)
4.改變博客標題
先放效果圖
這兩個在離開當前博客的標簽頁以及點進去的時候會出現,2s之後會消失,並不會影響閱讀
需要在頁腳html中加入以下代碼:
修改方法有註釋在代碼中
<div style = "display:none;" > 瀏覽器標題切換 </div>
<script>
var OriginTitile = document.title; // 保存之前頁面標題
var titleTime;
document.addEventListener('visibilitychange', function(){
if (document.hidden){
document.title ='你不要我了麽?qwq'; // 切出文字
clearTimeout(titleTime);
}else{
document.title = '歡迎回來~'; // 切入文字
titleTime = setTimeout(function() {
document.title = OriginTitile;
}, 1000); // 2秒後恢復原標題
}
});
</script>
<div style = "display:none;" > 瀏覽器標題切換end </div>
5.背景中的動態線條
我的博客背景有點花,可能鼠標得停下來久一點才看得清
也可以去其他博客背景中有動態線條的看看效果圖
這裏就直接給代碼了,放入側邊欄即可
<div style = "display:none;">動態線條</div>
<script>
!function(){
function n(n,e,t){
return n.getAttribute(e)||t
}
function e(n){
return document.getElementsByTagName(n)
}
function t(){
var t=e("script"),o=t.length,i=t[o-1];
return{
l:o,z:n(i,"zIndex",-1),o:n(i,"opacity",.5),c:n(i,"color","0,0,0"),n:n(i,"count",99)
}
}
function o(){
a=m.width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,
c=m.height=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight
}
function i(){
r.clearRect(0,0,a,c);
var n,e,t,o,m,l;
s.forEach(function(i,x){
for(i.x+=i.xa,i.y+=i.ya,i.xa*=i.x>a||i.x<0?-1:1,i.ya*=i.y>c||i.y<0?-1:1,r.fillRect(i.x-.5,i.y-.5,1,1),e=x+1;e<u.length;e++)n=u[e],
null!==n.x&&null!==n.y&&(o=i.x-n.x,m=i.y-n.y,
l=o*o+m*m,l<n.max&&(n===y&&l>=n.max/2&&(i.x-=.03*o,i.y-=.03*m),
t=(n.max-l)/n.max,r.beginPath(),r.lineWidth=t/2,r.strokeStyle="rgba("+d.c+","+(t+.2)+")",r.moveTo(i.x,i.y),r.lineTo(n.x,n.y),r.stroke()))
}),
x(i)
}
var a,c,u,m=document.createElement("canvas"),
d=t(),l="c_n"+d.l,r=m.getContext("2d"),
x=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||
function(n){
window.setTimeout(n,1e3/45)
},
w=Math.random,y={x:null,y:null,max:2e4};m.id=l,m.style.cssText="position:fixed;top:0;left:0;z-index:"+d.z+";opacity:"+d.o,e("body")[0].appendChild(m),o(),window.onresize=o,
window.onmousemove=function(n){
n=n||window.event,y.x=n.clientX,y.y=n.clientY
},
window.onmouseout=function(){
y.x=null,y.y=null
};
for(var s=[],f=0;d.n>f;f++){
var h=w()*a,g=w()*c,v=2*w()-1,p=2*w()-1;s.push({x:h,y:g,xa:v,ya:p,max:6e3})
}
u=s.concat([y]),
setTimeout(function(){i()},100)
}();
</script>
<div style = "display:none;"> 動態線條end</div>
6.目錄
右下角的目錄,還是挺有用的吧?
但是這玩意我自己真的搞不來,自己把文件下載下來之後復原不出別人的那個樣子...
所以直接從別人博客上面找的代碼了...源文件也是別人博客的
但是我找不到當時的那個博客了,如果博主有看到這篇文章的話可以在評論區裏說一下我給加個鏈接在這
代碼:
<div style = "display:none;" >index相關</div>
<script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="http://files.cnblogs.com/files/ning-wang/marvin.nav.css" rel="stylesheet">
<script type="text/javascript" src="http://files.cnblogs.com/files/ning-wang/marvin.nav.js"></script>
<div style = "display:none;" >index相關end</div>
7.旋轉立方體
在博客側邊欄的旋轉立方體,圖片可以自行更換
<div style = "display:none;">旋轉立方體</div>
<style>
/*最外層容器樣式*/
.wrap {
width: 100px;
height: 100px;
margin: 150px;
position: relative;
}
/*包裹所有容器樣式*/
.cube {
width: 50px;
height: 50px;
margin: 0 auto;
transform-style: preserve-3d;
transform: rotateX(-30deg) rotateY(-80deg);
animation: rotate linear 20s infinite;
}
@-webkit-keyframes rotate {
from {
transform: rotateX(0deg) rotateY(0deg);
}
to {
transform: rotateX(360deg) rotateY(360deg);
}
}
.cube div {
position: absolute;
width: 200px;
height: 200px;
opacity: 0.8;
transition: all .4s;
}
/*定義所有圖片樣式*/
.pic {
width: 200px;
height: 200px;
}
.cube .out_front {
transform: rotateY(0deg) translateZ(100px);
}
.cube .out_back {
transform: translateZ(-100px) rotateY(180deg);
}
.cube .out_left {
transform: rotateY(-90deg) translateZ(100px);
}
.cube .out_right {
transform: rotateY(90deg) translateZ(100px);
}
.cube .out_top {
transform: rotateX(90deg) translateZ(100px);
}
.cube .out_bottom {
transform: rotateX(-90deg) translateZ(100px);
}
/*定義小正方體樣式*/
.cube span {
display: block;
width: 100px;
height: 100px;
position: absolute;
top: 50px;
left: 50px;
}
.cube .in_pic {
width: 100px;
height: 100px;
}
.cube .in_front {
transform: rotateY(0deg) translateZ(50px);
}
.cube .in_back {
transform: translateZ(-50px) rotateY(180deg);
}
.cube .in_left {
transform: rotateY(-90deg) translateZ(50px);
}
.cube .in_right {
transform: rotateY(90deg) translateZ(50px);
}
.cube .in_top {
transform: rotateX(90deg) translateZ(50px);
}
.cube .in_bottom {
transform: rotateX(-90deg) translateZ(50px);
}
/*鼠標移入後樣式*/
.cube:hover .out_front {
transform: rotateY(0deg) translateZ(200px);
}
.cube:hover .out_back {
transform: translateZ(-200px) rotateY(180deg);
}
.cube:hover .out_left {
transform: rotateY(-90deg) translateZ(200px);
}
.cube:hover .out_right {
transform: rotateY(90deg) translateZ(200px);
}
.cube:hover .out_top {
transform: rotateX(90deg) translateZ(200px);
}
.cube:hover .out_bottom {
transform: rotateX(-90deg) translateZ(200px);
}
</style>
<!-- 外層最大容器 -->
<div class="wrap">
<!--包裹所有元素的容器-->
<div class="cube">
<!--前面圖片 -->
<div class="out_front">
<img src="https://i.loli.net/2018/05/03/5aeb0eef73838.jpg" class="pic">
</div>
<!--後面圖片 -->
<div class="out_back">
<img src="https://i.loli.net/2018/05/03/5aeb0f2fb9a83.jpg" class="pic">
</div>
<!--左面圖片 -->
<div class="out_left">
<img src="https://i.loli.net/2018/05/03/5aeb0f55411f0.jpg" class="pic">
</div>
<!--右面圖片 -->
<div class="out_right">
<img src="https://i.loli.net/2018/05/03/5aeb0f79a1124.jpg" class="pic">
</div>
<!--上面圖片 -->
<div class="out_top">
<img src="https://i.loli.net/2018/05/03/5aeb0f98a8b66.jpg" class="pic">
</div>
<!--下面圖片 -->
<div class="out_bottom">
<img src="https://i.loli.net/2018/05/03/5aeb0fdd51b7e.jpg" class="pic">
</div>
<!--小正方體 -->
<span class="in_front">
<img src="https://i.loli.net/2018/05/03/5aeb100223dd0.jpg" class="in_pic">
</span>
<span class="in_back">
<img src="https://i.loli.net/2018/05/03/5aeb101c2c24b.jpg" class="in_pic">
</span>
<span class="in_left">
<img src="https://i.loli.net/2018/05/03/5aeb1038127b5.jpg" class="in_pic">
</span>
<span class="in_right">
<img src="https://i.loli.net/2018/05/03/5aeb0dce1ca55.jpg" class="in_pic">
</span>
<span class="in_top">
<img src="https://i.loli.net/2018/05/03/5aeb1057bb167.jpg" class="in_pic">
</span>
<span class="in_bottom">
<img src="https://i.loli.net/2018/05/03/5aeb107514579.jpg" class="in_pic">
</span>
</div>
</div>
<div style = "display:none;">旋轉立方體end</div>
8.代碼高亮
代碼高亮來自Angel_Kitty
在頁面定制css中加入
/*! Color themes for Google Code Prettify | MIT License | github.com/jmblog/color-themes-for-google-code-prettify */
.pln{color:#4d4d4c}ol.linenums{margin-top:0;margin-bottom:0;color:#8e908c}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{padding-left:1em;background-color:#fff;list-style-type:decimal!important;}@media screen{.str{color:#718c00}.kwd{color:#8959a8}.com{color:#8e908c}.typ{color:#4271ae}.lit{color:#f5871f}.pun{color:#4d4d4c}.opn{color:#4d4d4c}.clo{color:#4d4d4c}.tag{color:#c82829}.atn{color:#f5871f}.atv{color:#3e999f}.dec{color:#f5871f}.var{color:#c82829}.fun{color:#4271ae}}
/*下面是我設置背景色,字體大小和字體*/
.cnblogs-markdown code{
background:#fff!important;
}
.cnblogs_code,.cnblogs_code span,.cnblogs-markdown .hljs{
font-size:16px!important;
}
.syntaxhighlighter a, .syntaxhighlighter div, .syntaxhighlighter code, .syntaxhighlighter table, .syntaxhighlighter table td, .syntaxhighlighter table tr, .syntaxhighlighter table tbody, .syntaxhighlighter table thead, .syntaxhighlighter table caption, .syntaxhighlighter textarea {
font-size: 16px!important;
}
.cnblogs_code, .cnblogs_code span, .cnblogs-markdown .hljs{
font-family:consolas, "Source Code Pro", monaco, monospace !important;
}
在頁腳html加入
<script src="http://files.cnblogs.com/files/flipped/prettify.js"></script>
<script type="text/javascript">
(function() {
$("pre").addClass("prettyprint");
prettyPrint();
})();
</script>
博客園美化筆記