简体   繁体   English

如何覆盖暗/亮模式切换的 css?

[英]How to override css for Dark/Light Mode Toggle?

I am trying hard to use W3Scholls Dark Mode Toggle for my webiste but what happens is that the background of my website doesn't changes.我正在努力为我的网站使用W3Scholls 暗模式切换,但发生的情况是我网站的背景没有改变。

This is my Test Websit Page in which only stars could change their colour after Toggle Button is clicked.这是我的测试网站页面,其中只有星星可以在单击切换按钮后改变它们的颜色。

I would be grateful for helping me override the style for website Test Page.如果能帮助我覆盖网站测试页的样式,我将不胜感激。

you need to understand that the W3Scholls example is just an example.您需要了解 W3Scholls 示例只是一个示例。 your body's background is not showing so changing it won't show.你身体的背景没有显示,所以改变它不会显示。 if for example, you changed the background for the about-area div you will see it.例如,如果您更改了about-area div 的背景,您将看到它。 you need to elaborate every style in every element you want to change and then connect it with the dark-mode selector.您需要详细说明要更改的每个元素中的每种样式,然后将其与dark-mode选择器连接起来。

example:例子:

body.dark-mode .about-area {
    background: black;
}

body.dark-mode p {
    color: white;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM