经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
如何简单美化自己的博客(二)——主界面样式及点击特效
来源:cnblogs  作者:是卡门啊  时间:2020/12/14 17:04:13  对本文有异议

博客主体样式更改

  1. 首先选一个框架模板,在此模板基础上进行样式调整。这里我选择darkgreentrip
  2. 在页面定制CSS代码中插入如下代码:
  1. #home {
  2. margin: 0 auto;
  3. width: 80%;/*原始65*/
  4. min-width: 980px;/*页面顶部的宽度*/
  5. background-color: rgba(245, 245, 245, 0.7);
  6. padding: 30px;
  7. margin-top: 50px;
  8. margin-bottom: 50px;
  9. box-shadow: 0 2px 6px rgba(100, 100, 100, 0.3);
  10. border-radius: 12px; /*调节边框圆度*/
  11. }
  12. /*boby调节背景图片*/
  13. body {
  14. background:url("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606476513478&di=92fdb162c0020c2b43d20fa5ffae2159&imgtype=0&src=http%3A%2F%2Fimage.biaobaiju.com%2Fuploads%2F20191015%2F15%2F1571124483-pUBXSkAZba.jpg"); /*背景图片链接*/
  15. background-position:center left;
  16. background-size: cover;
  17. background-repeat: no-repeat;
  18. background-attachment:fixed;
  19. }
  20. #blogTitle {
  21. height: 100%; /*高度*/
  22. border-radius: 12px;
  23. clear: both;
  24. background-color: #cccccc69; /*博客标题的背景*/
  25. }
  26. #blogTitle h1 {
  27. font-size: 36px;
  28. color::#fae4e4;
  29. font-weight: bold;
  30. line-height: 1.8em;/*原始 1.6em*/
  31. margin-top: 10px;/*原始 15px */
  32. }
  33. #blogTitle h2 {
  34. font-weight: normal;
  35. font-size: 17px; /*原始 16px ;font-size: 1.0rem;*/
  36. line-height: 1.8;
  37. color: #462b2e;
  38. font-weight: bold;
  39. text-align: right;
  40. float: right;
  41. margin-top: auto;
  42. }
  43. #navigator{
  44. border-radius: 7px;
  45. background-color: rgba(201, 49, 49, 0.6); /*标题栏下的颜色*/
  46. }
  47. #navList a:link, #navList a:visited, #navList a:active{
  48. color: #FFFFFF;
  49. font-size: 18px;
  50. font-weight: bold;
  51. }
  52. .blogStats{
  53. color: #eee;
  54. }
  55. .postTitle {
  56. border-left: 8px solid rgba(132,112,255, 0);
  57. margin-left: 10px;
  58. margin-bottom: 10px;
  59. font-size: 20px;
  60. float: right;
  61. width: 100%;
  62. clear: both;
  63. }
  64. .postTitle a:link, .postTitle a:visited, .postTitle a:active {
  65. color: #ac0e0e;
  66. transition: all 0.4s linear 0s;
  67. }
  68. .postTitle a:hover {
  69. margin-left: 30px;
  70. color: #ac0e0e;
  71. text-decoration: none;
  72. }
  73. .postCon {
  74. float: right;
  75. line-height: 1.5em;
  76. width: 100%;
  77. clear: both;
  78. padding: 10px 0;
  79. }
  80. .day .postTitle a {
  81. padding-left: 10px;
  82. }
  83. .day {
  84. background: rgba(255, 255, 255, 0.5);
  85. }
  86. /*文章附加信息*/
  87. .postDesc {
  88. /* background: gray no-repeat 0 1px; */
  89. color: #852222;
  90. float: left;
  91. width: 90%;
  92. clear: both;
  93. text-align: left;
  94. font-family: "微软雅黑" , "宋体" , "黑体" ,Arial;
  95. font-size: 13px;
  96. /*padding-right: 20px;5px padding-left: 90px;posted 发表时间左边距离*/
  97. margin-right:20px;
  98. /* margin-top: 20px;*/
  99. line-height: 1.8;
  100. /* padding-bottom: 35px; */
  101. }
  102. .newsItem, .catListEssay, .catListLink, .catListNoteBook, .catListTag, .catListPostCategory,
  103. .catListPostArchive, .catListImageCategory, .catListArticleArchive, .catListView,
  104. .catListFeedback, .mySearch, .catListComment, .catListBlogRank, .catList, .catListArticleCategory ,#blog-calendar
  105. {
  106. background: rgba(255, 255, 255, 0.5);
  107. margin-bottom: 25px;
  108. word-wrap: break-word;
  109. }
  110. .CalTitle{
  111. background: rgba(255, 255, 255, 0);
  112. }
  113. .catListTitle{
  114. margin-top: auto;
  115. margin-bottom: auto;
  116. background-color: rgba(201, 49, 49, 0.6); /*栏目的条纹颜色*/
  117. border-bottom: none;
  118. }
  119. #topics{
  120. background: rgba(255, 255, 255, 0.5);
  121. }
  122. .c_ad_block{
  123. display: none;
  124. }
  125. #tbCommentBody{
  126. width: 100%;
  127. height: 200px;
  128. background: rgba(255, 255, 255, 0.5);
  129. }
  130. #q,#google_q{
  131. background: rgba(255, 255, 255, 0);
  132. }
  133. .CalNextPrev{
  134. background: rgba(255, 255, 255, 0);
  135. }
  136. .cnblogs_code{
  137. background: rgba(255, 255, 255, 0);
  138. }
  139. .dayTitle{
  140. display: none;
  141. font-size: 18px;
  142. }
  143. .cnblogs_code div{
  144. background: rgba(255, 255, 255, 0);
  145. }
  146. .cnblogs_code_toolbar{
  147. background: rgba(255, 255, 255, 0);
  148. }
  149. #main{
  150. min-width: 640px;
  151. }
  152. .entrylist{
  153. background: rgba(255, 255, 255, 0.5);
  154. min-height: 60px;
  155. }
  156. .CalTodayDay{
  157. font-weight: 700;
  158. color: rgba(201, 49, 49, 0.8);
  159. background: #f533;
  160. }
  161. a.entrylistItemTitle{
  162. color: #ac0e0e;
  163. }
  164. .entrylistTitle,.entrylistDescription{
  165. display:none;
  166. }
  167. .entrylistItem{
  168. margin-bottom: auto;
  169. }
  170. .entrylistItemPostDesc, .entrylistItem>.entrylistItemPostDesc>a:nth-child(1){
  171. color: #852222;
  172. }
  173. .entrylistPostSummary{
  174. color: #666;
  175. }
  176. .comment_textarea{
  177. background: rgba(255, 255, 255, 0.5);
  178. border-radius: 7px;
  179. }
  180. td>a>u{
  181. /*text-decoration:none;*/
  182. color: #852222;
  183. }
  184. div>ul{
  185. margin-bottom: auto;
  186. }

大家可以根据自己的喜好,更改对应的颜色配置、界面宽度、主题背景(可以百度搜索到喜欢的图片后,点击复制图片地址,替换代码中的地址)等。
PS:给一些小建议,如果有想要更改的样式,而找不到的话,建议在自己的博客下打开F12,出现控制台后,点击如下图的按钮

然后去页面中点击自己想要更改的内容,如下图:

点击后,控制台就会出现相应的HTML及css代码,如下图:

可以先在控制台对选择的CSS代码中更改,预览效果,然后再来后台更改。

鼠标效果

  1. 鼠标图案效果
    在页面定制CSS如下代码片段中,插入下列(最后一行)代码:
  1. /*boby调节背景图片*/
  2. body {
  3. background:url("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606476513478&di=92fdb162c0020c2b43d20fa5ffae2159&imgtype=0&src=http%3A%2F%2Fimage.biaobaiju.com%2Fuploads%2F20191015%2F15%2F1571124483-pUBXSkAZba.jpg"); /*背景图片链接*/
  4. background-position:center left;
  5. background-size: cover;
  6. background-repeat: no-repeat;
  7. background-attachment:fixed;
  8. cursor: url(https://files.cnblogs.com/files/wkfvawl/cursor.ico),auto; /*鼠标效果*/
  9. }

展示效果如图:

如果想换成其他自己喜欢的图标,可以去百度在线制作ico的网站(例如:http://www.ico51.cn/),先上传自己想要做成ico的图片(如果找不到合适的可以去阿里巴巴矢量图标库去找免费下载的),然后自己选择像素大小,一般这里选择32*32的就可以了。如下:

生成了ico之后,保存到本地,然后上传到博客园设置->文件。
然后将cursor: url(https://files.cnblogs.com/files/wkfvawl/cursor.ico),auto中的路径,改为你的文件路径https://blog-static.cnblogs.com/files/你的博客园名/favicon.ico
效果:

2. 鼠标点击效果

  • 点击文字
    将下面的代码复制到首页HTML代码块:
  1. <script type="text/javascript">
  2. /* 鼠标点击特效 */
  3. var a_idx = 0;
  4. jQuery(document).ready(function($) {
  5. $("body").click(function(e) {
  6. /* 内容可以更换为自己喜欢的 */
  7. var a = new Array("?富强?","?民主?","?文明?","?和谐?","?自由?","?平等?","?公正?","?法治?","?爱国?","?敬业?","?诚信?","?友善?");
  8. var $i = $("<span></span>").text(a[a_idx]);
  9. a_idx = (a_idx + 1) % a.length;
  10. var x = e.pageX,
  11. y = e.pageY;
  12. $i.css({
  13. "z-index": 999,
  14. "top": y - 20,
  15. "left": x,
  16. "position": "absolute",
  17. "font-weight": "bold",
  18. "color": "rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")" /* 随机颜色 */
  19. });
  20. $("body").append($i);
  21. $i.animate({
  22. "top": y - 180,
  23. "opacity": 0
  24. },
  25. 1500,
  26. function() {
  27. $i.remove();
  28. });
  29. });
  30. });
  31. </script>
  • 烟花效果
    将下列代码复制到页脚HTML代码中去:
  1. <script src="https://files.cnblogs.com/files/nthforsth/mouse-click.js"></script>
  2. <canvas width="1777" height="841" style="position: fixed; left: 0px; top: 0px; z-index: 2147483647; pointer-events: none;"></canvas>

如果已经有了雪花特效的代码,需要放到和雪花特效的script同级,如下:

最终效果图如下:

原文链接:http://www.cnblogs.com/Carmena/p/14109906.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号