修改主题颜色和样式

主题样式变量

下面是vdoing主题使用的css变量,你可以在.vuepress/styles/palette.styl修改这些变量覆盖它们:

  1. //***vdoing主题-CSS变量***//
  2. // 颜色
  3. $bannerTextColor = #fff // 首页banner区(博客标题区)的文本颜色
  4. $accentColor = #11A8CD
  5. $activeColor = #ff5722
  6. $arrowBgColor = #ccc
  7. $badgeTipColor = #42b983
  8. $badgeWarningColor = darken(#ffe564, 35%)
  9. $badgeErrorColor = #DA5961
  10. // 布局
  11. $navbarHeight = 3.6rem
  12. $sidebarWidth = 18rem
  13. $contentWidth = 860px
  14. $homePageWidth = 1100px
  15. $rightMenuWidth = 230px // 右侧菜单
  16. // 代码块
  17. $lineNumbersWrapperWidth = 2.5rem
  18. // 浅色模式
  19. .theme-mode-light
  20. --bodyBg: #f4f4f4
  21. --mainBg: rgba(255,255,255,1)
  22. --sidebarBg: rgba(255,255,255,.8)
  23. --blurBg: rgba(255,255,255,.9)
  24. --textColor: #004050
  25. --textLightenColor: #0085AD
  26. --borderColor: rgba(0,0,0,.15)
  27. // 代码块浅色主题
  28. --codeBg: #f6f6f6
  29. --codeColor: #525252
  30. codeThemeLight()
  31. // 代码块深色主题
  32. // --codeBg: #252526
  33. // --codeColor: #fff
  34. // codeThemeDark()
  35. // 深色模式
  36. .theme-mode-dark
  37. --bodyBg: rgb(39,39,43)
  38. --mainBg: rgba(30,30,34,1)
  39. --sidebarBg: rgba(30,30,34,.8)
  40. --blurBg: rgba(30,30,34,.8)
  41. --textColor: rgb(140,140,150)
  42. --textLightenColor: #0085AD
  43. --borderColor: #2C2C3A
  44. --codeBg: #252526
  45. --codeColor: #fff
  46. codeThemeDark()
  47. // 阅读模式
  48. .theme-mode-read
  49. --bodyBg: rgb(240,240,208)
  50. --mainBg: rgba(245,245,213,1)
  51. --sidebarBg: rgba(245,245,213,.8)
  52. --blurBg: rgba(245,245,213,.9)
  53. --textColor: #004050
  54. --textLightenColor: #0085AD
  55. --borderColor: rgba(0,0,0,.15)
  56. --codeBg: #282c34
  57. --codeColor: #fff
  58. codeThemeDark()

上面的变量值可能不是最新的,最新的变量值可查看:palette.styl

样式修改与适配

当你想修改主题某个地方的样式时,或者你在给博客添加了一些新的模块或插件,发现样式和主题的样式不协调时,都可以在.vuepress/styles/index.styl 添加css样式来做修改。 需要注意的是,你在自己写的css样式中,请尽量使用主题提供的变量来进行适配。

小技巧:当你发现自己写的css样式优先级没有原来的样式高时,可以在样式后面添加!improtant后缀,使你的样式优先级是最高的。