博客CSS样式 二
预览
可自行更改颜色
背景图
页面定制 CSS 代码中加入:
url为背景图地址,可下载心仪背景图后上传到博客园相册后获取地址
body { color: #000; background: url(https://images.cnblogs.com/cnblogs_com/csyzlm/1893888/o_201204093736timg.jpg) fixed; background-size:100% 100%; background-repeat: no-repeat; font-family: "Helvetica Neue",Helvetica,Verdana,Arial,sans-serif; font-size: 12px; }
目录样式
页面定制 CSS 代码中加入:
#cnblogs_post_body h1 { font-size: 250%; color: #01163; /* box-shadow: 0 0 0 1px #5F5A4B, 0px 0px 6px 0px rgba(10, 10, 0, 0.5); */ /* text-shadow: 1px 1px 1px #222222;*/ /* padding: 5px 0 5px 20px; */ margin:0px 0px 15px 0px; text-align: center; } #navCategory { color: #e7288f !important; } #navCategory li a { color:#e7288f !important; } #cnblogs_post_body h3 { display: inline-block; font-size: 16px; color: #333; padding: 6px 12px; background: #f2f2f2; border-radius: 4px; } #cnblogs_post_body h4 { padding: 6px 12px; } #cnblogs_post_body h5 { color: #FB02F9; padding: 3px 0 3px 21px; font-size: 12px; font-weight: bold; height: 14px; line-height: 14px; } #cnblogs_post_body h2 { font-size: 18px; color: #333; padding: 8px 12px; background: #f2f2f2; border-radius: 4px; }
目录索引
页脚 HTML 代码加入:
<script language="javascript" type="text/javascript"> // 生成目录索引列表 // ref: http://www.cnblogs.com/wangqiguo/p/4355032.html // modified by: zzq function GenerateContentList() { var mainContent = $('#cnblogs_post_body'); var h2_list = $('#cnblogs_post_body h2');//如果你的章节标题不是h2,只需要将这里的h2换掉即可 if(mainContent.length < 1) return; if(h2_list.length>0) { var content = '<a name="_labelTop"></a>'; content += '<div id="navCategory" style="color:#268FA6;">'; content += '<p style="font-size:18px;"><b>目录</b></p>'; content += '<ul>'; for(var i=0; i<h2_list.length; i++) { var go_to_top = '<div style="text-align: right;"><a href="#_labelTop" style="color:#e7288f">Top</a><a name="_label' + i + '"></a></div>'; $(h2_list[i]).before(go_to_top); var h3_list = $(h2_list[i]).nextAll("h3"); var li3_content = ''; for(var j=0; j<h3_list.length; j++) { var tmp = $(h3_list[j]).prevAll('h2').first(); if(!tmp.is(h2_list[i])) break; var li3_anchor = '<a name="_label' + i + '_' + j + '"></a>'; $(h3_list[j]).before(li3_anchor); li3_content += '<li><a href="#_label' + i + '_' + j + '" style="color:#268FA6" >' + $(h3_list[j]).text() + '</a></li>'; } var li2_content = ''; if(li3_content.length > 0) li2_content = '<li><a href="#_label' + i + '" style="color:#268FA6">' + $(h2_list[i]).text() + '</a><ul>' + li3_content + '</ul></li>'; else li2_content = '<li><a href="#_label' + i + '" style="color:#268FA6">' + $(h2_list[i]).text() + '</a></li>'; content += li2_content; } content += '</ul>'; content += '</div><p> </p>'; content += '<hr style="height:1px;border:none;border-top:1px dashed #0066CC;"/>'; if($('#cnblogs_post_body').length != 0 ) { $($('#cnblogs_post_body')[0]).prepend(content); } } } GenerateContentList(); </script>