---
title: "Discussion on \"CSS+Javascript 实现暗黑模式\" | Hashnode"
description: "Discussion on \"CSS+Javascript 实现暗黑模式\". 学习的过程中尝试自己去写模版切换的功能，发现写完以后对设计系统颜色的定义理解更深入了。\n这里用的方法主要是通过定义 --example 的颜色变亮，以及 .dark 的方式实现页面的两套配色。最后通过 javascript 监听 botton 的点击事件替换css的变亮到 .dark 定义的内容。\nbody {\n    --accent-color:#4E6E0C;\n    --accent-color-hovered:#415C0A;\n    --background-color:#F0FBD..."
url: "https://hashnode.com/posts/cssjavascript/60ab715961f5f47b572b55b6"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [CSS+Javascript 实现暗黑模式](https://blog.chenli.cool/cssjavascript?utm_source=hashnode&utm_medium=feed)

学习的过程中尝试自己去写模版切换的功能，发现写完以后对设计系统颜色的定义理解更深入了。 这里用的方法主要是通过定义 --example 的颜色变亮，以及 .dark 的方式实现页面的两套配色。最后通过 javascript 监听 botton 的点击事件替换css的变亮到 .dark 定义的内容。 body { --accent-color:#4E6E0C; --accent-color-hovered:#415C0A; --background-color:#F0FBD...

May 9, 2019 · 1 min read · blog.chenli.cool  
Read the article

-   [#learn-coding](https://hashnode.com/tag/learn-coding)
-   [#css](https://hashnode.com/tag/css)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[A-Li](https://hashnode.com/@A-Li)

@A-Li · Beijing, China

  
[View profile](https://hashnode.com/@A-Li)

产品体验设计师

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
