博客园自定义样式可以制作各种精美的效果,下面是我的博客园地址和制作方式:
我的博客园

首页样式

首页html

  1. <!-- 首页样式 -->
  2. <link href="http://files.cnblogs.com/files/liyunhua/cnblogBlack.css" rel="stylesheet" />

去广告

页面css

  1. #google_ad_c1,#div-gpt-ad-1320933818841-0,#google_ad_c2,#div-gpt-ad-1320933818841-1,#ad_under_google{
  2. display:none;
  3. visibilityhidden;
  4. }

markdown格式美化

页面css

  1. /* 文章标题样式(这个不是markdown里的标题) */
  2. #topics .postTitle a {
  3. color: #000000;
  4. }
  5. /* 普通文字样式 */
  6. #cnblogs_post_body p {
  7. margin: 18px auto;
  8. color: #000;
  9. font-family: Consolas, "Microsoft YaHei", monospace;
  10. font-size: 16px;
  11. text-indent: 0;
  12. }
  13. /* 标题样式 */
  14. #cnblogs_post_body h1 {
  15. margin-bottom: 1em;
  16. margin-right: 5px;
  17. padding: 8px 15px;
  18. letter-spacing: 2px;
  19. background-image: linear-gradient(to right bottom, rgb(0, 188, 212), rgb(63, 81, 181));
  20. background-color: rgb(63, 81, 181);
  21. color: rgb(255, 255, 255);
  22. border-left: 10px solid rgb(51, 51, 51);
  23. border-radius: 5px;
  24. text-shadow: rgb(102, 102, 102) 1px 1px 1px;
  25. box-shadow: rgb(102, 102, 102) 1px 1px 2px;
  26. }
  27. #cnblogs_post_body h2 {
  28. font-family: Consolas, "Microsoft YaHei", monospace;
  29. font-size: 26px;
  30. font-weight: bold;
  31. line-height: 1.5;
  32. margin: 20px 0;
  33. }
  34. #cnblogs_post_body h3 {
  35. font-family: Consolas, "Microsoft YaHei", monospace;
  36. font-size: 20px;
  37. font-weight: bold;
  38. line-height: 1.5;
  39. margin: 10px 0;
  40. }
  41. #cnblogs_post_body h4 {
  42. font-family: Consolas, "Microsoft YaHei", monospace;
  43. font-size: 18px;
  44. font-weight: bold;
  45. margin: 10px 0;
  46. }
  47. /* 标题样式设置结束 */
  48. /* 去除双下划线斜体样式 */
  49. em {
  50. font-style: normal;
  51. color: #000;
  52. }
  53. /* 无序列表 */
  54. #cnblogs_post_body ul li {
  55. font-family: Consolas, "Microsoft YaHei", monospace;
  56. color: #000;
  57. font-size: 16px;
  58. list-style-type: disc;
  59. }
  60. /* 有序列表 */
  61. #cnblogs_post_body ol li {
  62. font-family: Consolas, "Microsoft YaHei", monospace;
  63. color: #000;
  64. font-size: 16px;
  65. list-style-type: decimal;
  66. }
  67. /* 超链接 */
  68. #cnblogs_post_body a:link {
  69. text-decoration: none;
  70. color: #002C99;
  71. }
  72. /* 引用 */
  73. #topics .postBody blockquote {
  74. background: #FFFFFF;
  75. border: none;
  76. border-left: 5px solid #CCCCCC;
  77. margin: 2px 0;
  78. padding-left: 6px;
  79. padding-top: 0px;
  80. padding-bottom: 0px;
  81. min-height: 0;
  82. }
  83. /* 单行代码 */
  84. .cnblogs-markdown code {
  85. font-family: Consolas, "Microsoft YaHei", monospace !important;
  86. font-size: 16px!important;
  87. line-height: 20px;
  88. border: 1px solid #ccc!important;
  89. padding: 0 5px!important;
  90. border-radius: 3px!important;
  91. line-height: 1.8;
  92. margin: 1px 5px;
  93. vertical-align: middle;
  94. display: inline-block;
  95. }
  96. /* 多行代码, 引用 */
  97. .cnblogs-markdown .hljs {
  98. font-family: Consolas, "Microsoft YaHei", monospace !important;
  99. font-size: 16px!important;
  100. line-height: 1.5!important;
  101. padding: 5px!important;
  102. }

访问次数统计

去注册一个

http://www.amazingcounters.com/

侧边公共栏

  1. <div style="font-size:15px;font-weight:bold;">访问次数:&nbsp;<a href="http://www.amazingcounters.com"><img border="0" src="http://cc.amazingcounters.com/counter.php?i=3214316&c=9643261" alt="AmazingCounters.com" height="30"></a></div>

github链接

页首html

  1. <a href="https://github.com/tianyunperfect"><img style="position: fixed; top: 0; right: 0; border: 0;z-index: 10000;" src="http://files.cnblogs.com/files/landeanfen/o_github.bmp"></a>

背景动画

页首html

  1. <!-- 背景动画 -->
  2. <canvas id="c_n9" width="1920" height="990" style="position: fixed; top: 0px; left: 0px; z-index: -1; opacity: 0.5;"></canvas>
  3. <script src="https://files.cnblogs.com/files/jingmoxukong/canvas-nest.min.js"></script>

添加目录导航

页面定制CSS

  1. /* 定制生成博客目录的CSS样式 */
  2. #uprightsideBar{
  3. font-size:16px;
  4. font-family:Arial, Helvetica, sans-serif;
  5. text-align:left;
  6. position:fixed;
  7. /*
  8. 将div的位置固定到距离top:150px,right:0px的位置,
  9. 这样div就会处在最右边的位置,距离顶部150px,
  10. 当然这两个值你可以自己改。
  11. */
  12. top:150px;
  13. right:0px;
  14. width: auto;
  15. height: auto;
  16. }
  17. #sideBarTab{
  18. float:left;
  19. width:25px;
  20. box-shadow: 0 0 8px #877788;
  21. border:1px solid #00DDC00;
  22. border-right:none;
  23. text-align:center;
  24. background:rgb(0, 220, 0);
  25. }
  26. #sideBarContents{
  27. float:left;
  28. overflow:auto;
  29. overflow-x:hidden;!important;
  30. width:200px;
  31. min-height:101px;
  32. max-height:460px;
  33. border:1px solid #e5e5e5;
  34. border-right:none;
  35. background:#ffffff;
  36. }
  37. #sideBarContents dl{
  38. margin:0;
  39. padding:0;
  40. }
  41. #sideBarContents dt{
  42. margin-top:5px;
  43. margin-left:5px;
  44. }
  45. #sideBarContents dd, dt {
  46. cursor: pointer;
  47. }
  48. #sideBarContents dd:hover, dt:hover {
  49. color:#A7995A;
  50. }
  51. #sideBarContents dd{
  52. margin-left:20px;
  53. }

页脚html

  1. <!-- 生成博客目录的JS代码,两级目录 -->
  2. <script type="text/javascript">
  3. /*
  4. 这段代码按H2、H3格式生成两级菜单
  5. 写博客按H2、H3格式写,不然生成不了
  6. Markdown写作按##、###两级目录写
  7. 当然你也可以改写代码成三级菜单
  8. 参考:孤傲苍狼 zhang_derek
  9. 洪卫 2018-5-18
  10. */
  11. var BlogDirectory = {
  12. /* 获取元素位置,距浏览器左边界的距离(left)和距浏览器上边界的距离(top)*/
  13. getElementPosition:function (ele) {
  14. var topPosition = 0;
  15. var leftPosition = 0;
  16. while (ele){
  17. topPosition += ele.offsetTop;
  18. leftPosition += ele.offsetLeft;
  19. ele = ele.offsetParent;
  20. }
  21. return {top:topPosition, left:leftPosition};
  22. },
  23. /*获取滚动条当前位置 */
  24. getScrollBarPosition:function () {
  25. var scrollBarPosition = document.body.scrollTop || document.documentElement.scrollTop;
  26. return scrollBarPosition;
  27. },
  28. /* 移动滚动条,finalPos 为目的位置,internal 为移动速度 */
  29. moveScrollBar:function(finalpos, interval) {
  30. //若不支持此方法,则退出
  31. if(!window.scrollTo) {
  32. return false;
  33. }
  34. //窗体滚动时,禁用鼠标滚轮
  35. window.onmousewheel = function(){
  36. return false;
  37. };
  38. //清除计时
  39. if (document.body.movement) {
  40. clearTimeout(document.body.movement);
  41. }
  42. //获取滚动条当前位置
  43. var currentpos =BlogDirectory.getScrollBarPosition();
  44. var dist = 0;
  45. //到达预定位置,则解禁鼠标滚轮,并退出
  46. if (currentpos == finalpos) {
  47. window.onmousewheel = function(){
  48. return true;
  49. }
  50. return true;
  51. }
  52. //未到达,则计算下一步所要移动的距离
  53. if (currentpos < finalpos) {
  54. dist = Math.ceil((finalpos - currentpos)/10);
  55. currentpos += dist;
  56. }
  57. if (currentpos > finalpos) {
  58. dist = Math.ceil((currentpos - finalpos)/10);
  59. currentpos -= dist;
  60. }
  61. var scrTop = BlogDirectory.getScrollBarPosition();//获取滚动条当前位置
  62. window.scrollTo(0, currentpos);//移动窗口
  63. if(BlogDirectory.getScrollBarPosition() == scrTop)//若已到底部,则解禁鼠标滚轮,并退出
  64. {
  65. window.onmousewheel = function(){
  66. return true;
  67. }
  68. return true;
  69. }
  70. //进行下一步移动
  71. var repeat = "BlogDirectory.moveScrollBar(" + finalpos + "," + interval + ")";
  72. document.body.movement = setTimeout(repeat, interval);
  73. },
  74. htmlDecode:function (text){
  75. var temp = document.createElement("div");
  76. temp.innerHTML = text;
  77. var output = temp.innerText || temp.textContent;
  78. temp = null;
  79. return output;
  80. },
  81. /*
  82. 创建博客目录,id表示包含博文正文的 div 容器的 id,
  83. mt 和 st 分别表示主标题和次级标题的标签名称(如 H2、H3,大写或小写都可以!),
  84. interval 表示移动的速度
  85. */
  86. createBlogDirectory:function (id, mt, st, interval){
  87. //获取博文正文div容器
  88. var elem = document.getElementById(id);
  89. if(!elem) return false;
  90. //获取div中所有元素结点
  91. var nodes = elem.getElementsByTagName("*");
  92. //创建博客目录的div容器
  93. var divSideBar = document.createElement('DIV');
  94. divSideBar.className = 'uprightsideBar';
  95. divSideBar.setAttribute('id', 'uprightsideBar');
  96. var divSideBarTab = document.createElement('DIV');
  97. divSideBarTab.setAttribute('id', 'sideBarTab');
  98. divSideBar.appendChild(divSideBarTab);
  99. var h2 = document.createElement('H2');
  100. divSideBarTab.appendChild(h2);
  101. var txt = document.createTextNode('目录导航');
  102. h2.appendChild(txt);
  103. var divSideBarContents = document.createElement('DIV');
  104. divSideBarContents.style.display = 'none';
  105. divSideBarContents.setAttribute('id', 'sideBarContents');
  106. divSideBar.appendChild(divSideBarContents);
  107. //创建自定义列表
  108. var dlist = document.createElement("dl");
  109. divSideBarContents.appendChild(dlist);
  110. var num = 0;//统计找到的mt和st
  111. mt = mt.toUpperCase();//转化成大写
  112. st = st.toUpperCase();//转化成大写
  113. //遍历所有元素结点
  114. for(var i=0; i<nodes.length; i++)
  115. {
  116. if(nodes[i].nodeName == mt|| nodes[i].nodeName == st)
  117. {
  118. //获取标题文本
  119. var nodetext = nodes[i].innerHTML.replace(/<\/?[^>]+>/g,"");//innerHTML里面的内容可能有HTML标签,所以用正则表达式去除HTML的标签
  120. nodetext = nodetext.replace(/ /ig, "");//替换掉所有的
  121. nodetext = BlogDirectory.htmlDecode(nodetext);
  122. //插入锚
  123. nodes[i].setAttribute("id", "blogTitle" + num);
  124. var item;
  125. switch(nodes[i].nodeName)
  126. {
  127. case mt: //若为主标题
  128. item = document.createElement("dt");
  129. break;
  130. case st: //若为子标题
  131. item = document.createElement("dd");
  132. break;
  133. }
  134. //创建锚链接
  135. var itemtext = document.createTextNode(nodetext);
  136. item.appendChild(itemtext);
  137. item.setAttribute("name", num);
  138. //添加鼠标点击触发函数
  139. item.onclick = function(){
  140. var pos = BlogDirectory.getElementPosition(document.getElementById("blogTitle" + this.getAttribute("name")));
  141. if(!BlogDirectory.moveScrollBar(pos.top, interval)) return false;
  142. };
  143. //将自定义表项加入自定义列表中
  144. dlist.appendChild(item);
  145. num++;
  146. }
  147. }
  148. if(num == 0) return false;
  149. /* 鼠标进入时的事件处理 */
  150. divSideBarTab.onmouseenter = function(){
  151. divSideBarContents.style.display = 'block';
  152. }
  153. /* 鼠标离开时的事件处理 */
  154. divSideBar.onmouseleave = function() {
  155. divSideBarContents.style.display = 'none';
  156. }
  157. document.body.appendChild(divSideBar);
  158. }
  159. };
  160. window.onload=function(){
  161. /* 页面加载完成之后生成博客目录 */
  162. BlogDirectory.createBlogDirectory("cnblogs_post_body","h1","h2",20);
  163. //为右下角推荐推荐区域添加关注按钮
  164. $('#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>');
  165. }
  166. </script>

添加打赏功能按键

用画图调整图片大小500像素-》 上传到博客园然后复制链接

页首html

  1. <!-- 添加打赏功能按键 -->
  2. <script src="http://static.tctip.com/tctip-1.0.0.min.js"></script>
  3. <script>
  4. new tctip({
  5. top: '60%',
  6. button: {
  7. id: 9,
  8. type: 'dashang',
  9. },
  10. list: [
  11. {
  12. type: 'alipay',
  13. qrImg: 'https://www.cnblogs.com/images/cnblogs_com/birdofparadise/1316472/o_aliPay.bmp'
  14. },
  15. {
  16. type: 'wechat',
  17. qrImg: 'https://www.cnblogs.com/images/cnblogs_com/birdofparadise/1316472/o_weixinPay.bmp'
  18. }
  19. ]
  20. }).init()
  21. </script>

鼠标点击心形特效

博客侧边栏公告代码:

  1. <!-- 为页面添加爱心特效 -->
  2. <script type="text/javascript">
  3. (function(window,document,undefined){
  4. var hearts = [];
  5. window.requestAnimationFrame = (function(){
  6. return window.requestAnimationFrame ||
  7. window.webkitRequestAnimationFrame ||
  8. window.mozRequestAnimationFrame ||
  9. window.oRequestAnimationFrame ||
  10. window.msRequestAnimationFrame ||
  11. function (callback){
  12. setTimeout(callback,1000/60);
  13. }
  14. })();
  15. init();
  16. function init(){
  17. 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;}");
  18. attachEvent();
  19. gameloop();
  20. }
  21. function gameloop(){
  22. for(var i=0;i<hearts.length;i++){
  23. if(hearts[i].alpha <=0){
  24. document.body.removeChild(hearts[i].el);
  25. hearts.splice(i,1);
  26. continue;
  27. }
  28. hearts[i].y--;
  29. hearts[i].scale += 0.004;
  30. hearts[i].alpha -= 0.013;
  31. 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;
  32. }
  33. requestAnimationFrame(gameloop);
  34. }
  35. function attachEvent(){
  36. var old = typeof window.onclick==="function" && window.onclick;
  37. window.onclick = function(event){
  38. old && old();
  39. createHeart(event);
  40. }
  41. }
  42. function createHeart(event){
  43. var d = document.createElement("div");
  44. d.className = "heart";
  45. hearts.push({
  46. el : d,
  47. x : event.clientX - 5,
  48. y : event.clientY - 5,
  49. scale : 1,
  50. alpha : 1,
  51. color : randomColor()
  52. });
  53. document.body.appendChild(d);
  54. }
  55. function css(css){
  56. var style = document.createElement("style");
  57. style.type="text/css";
  58. try{
  59. style.appendChild(document.createTextNode(css));
  60. }
  61. catch(ex){
  62. style.styleSheet.cssText = css;
  63. }
  64. document.getElementsByTagName('head')[0].appendChild(style);
  65. }
  66. function randomColor(){
  67. return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
  68. }
  69. })(window,document);
  70. </script>