博客自定义样式
本篇文章主要是用于记录自己设置过的博客样式,同时自己也在学习。
第一个样式
第一步:进入你的首页,打开管理->设置
第二步:我在博客皮肤中选择了SimpleMemory,这个皮肤相对来说要轻快、干净,更方便你来修改你的样式
第三部:我的代码部分
页首Html代码
<div id="midground" class="wall"></div> <div id="foreground" class="wall"></div> <div id="top" class="wall"></div>
页面定制CSS代码
#home h1{ font-size:45px; } body{ background-image: url("放你的背景图链接"); background-position: initial; background-size: cover; background-repeat: no-repeat; background-attachment: fixed; background-origin: initial; background-clip: initial; height:100%; width:100%; } #home{ opacity:0.7; } .wall{ position: fixed; top: 0; left: 0; bottom: 0; right: 0; } div#midground{ background: url("https://i.postimg.cc/PP5GtGtM/midground.png"); z-index: -1; -webkit-animation: cc 200s linear infinite; -moz-animation: cc 200s linear infinite; -o-animation: cc 200s linear infinite; animation: cc 200s linear infinite; } div#foreground{ background: url("https://i.postimg.cc/z3jZZD1B/foreground.png"); z-index: -2; -webkit-animation: cc 253s linear infinite; -o-animation: cc 253s linear infinite; -moz-animation: cc 253s linear infinite; animation: cc 253s linear infinite; } div#top{ background: url("https://i.postimg.cc/PP5GtGtM/midground.png"); z-index: -4; -webkit-animation: da 200s linear infinite; -o-animation: da 200s linear infinite; animation: da 200s linear infinite; } @-webkit-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @-o-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @-moz-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @keyframes cc { 0%{ background-position: 0 0; } 100%{ background-position: 600% 0; } } @keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-webkit-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-moz-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-ms-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } }
然后保存
效果图:
增加侧边目录栏
只能适配二、三、四级目录,当存在二级标题时,以二级标题为起始,否则以三级标题为起始,向下展示一级目录.

<script language="javascript" type="text/javascript"> function GenerateContentList(h23) { var mainContent = $('#cnblogs_post_body'); var h2_list = $('#cnblogs_post_body').children(h23); if (mainContent.length < 1) return; if (h2_list.length > 0) { var content = '<a name="_labelTop"></a>'; content += '<div id="navCategory">'; content += '<p id="mylist" style="font-size:30px"><b>目录</b></p>'; content += '<ul id="myul"><li style="text-align: right"><b id="guanbi" style="cursor: pointer">x</b></li>'; for (var i = 0; i < h2_list.length; i++) { var go_to_top = '<div style="text-align: right"><a href="#_labelTop">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 + '">' + $(h3_list[j]).text() + '</a></li>'; } var li2_content = ''; if (li3_content.length > 0) li2_content = '<li><a href="#_label' + i + '">' + $(h2_list[i]).text() + '</a><ul>' + li3_content + '</ul></li>'; else li2_content = '<li><a href="#_label' + i + '">' + $(h2_list[i]).text() + '</a></li>'; content += li2_content; } content += '</ul>'; if ($('#cnblogs_post_body').length != 0) { $($('#cnblogs_post_body')[0]).prepend(content); } } } if ($('#cnblogs_post_body h2').length > 0) { GenerateContentList('h2'); } else { GenerateContentList('h3'); } jQuery('#mylist').click(function () { var my_list = jQuery(this); var my_mulu = jQuery('#myul'); my_list.stop(); my_mulu.stop(); my_list.slideUp(400); my_mulu.fadeIn(600); }); $('#guanbi').click(function () { var my_list = jQuery('#mylist'); var my_mulu = jQuery('#myul'); my_list.stop(); my_mulu.stop(); my_list.slideDown(400); my_mulu.fadeOut(600); }) </script>

#navCategory { position: fixed; right: 0; top: 100px; list-style: none; z-index: 99999; } #navCategory > #mylist { position: absolute; background-color: white; width: 32px; left: -32px; font-size: 30px; font-weight: bold; border-radius: 5px; opacity: 0.8; } #navCategory > #myul { background-color: white; height: 400px; width: 230px; padding-top: 5px; overflow: auto; display: none; } #navCategory ul, #navCategory li { list-style: none !important; margin: 5px !important; }