# 深色/浅色模式切换在操作系统设置与切换设置不匹配时产生混合结果

**URL:** https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568
**Category:** Support
**Tags:** dark-mode-toggle
**Created:** [2025年十月23日 20:02 UTC](https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568 "2025-10-23T20:02:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kayla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayla/32/128523_2.png) [@Kayla](https://meta.discourse.org/u/Kayla)
#### Post date: [2025年十月23日 20:02 UTC](https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568/1 "2025-10-23T20:02:04Z")

</div>

当用户的操作系统设置为浅色模式，并且用户在侧边栏切换器中选择了深色模式时，我的主题组件中的 `@media (prefers-color-scheme: dark)` CSS 样式会被忽略。如果用户的操作系统设置为深色模式，但他们在侧边栏切换器中选择了浅色模式，我也会遇到奇怪的问题。当操作系统设置和切换器设置匹配模式时，一切看起来都符合预期。有没有其他人遇到过这个问题，并找到了在操作系统设置和侧边栏切换器设置不匹配时应用浅色/深色模式 CSS 调整的方法？

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025年十月31日 19:43 UTC](https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568/2 "2025-10-31T19:43:54Z")

</div>

您有自定义主题吗？在使用 Foundation 或 Horizon 时是否会出现同样的问题？

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025年十一月12日 21:02 UTC](https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568/3 "2025-11-12T21:02:13Z")

</div>

嗨 Kayla！您能自己弄清楚这个问题吗？如果可以，您能在这里分享结果吗？如果不能，我想我们最好删除这个话题。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2025年十一月14日 15:24 UTC](https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568/4 "2025-11-14T15:24:07Z")

</div>

`prefers-color-scheme` 仅考虑操作系统模式和颜色方案。  
为了使界面颜色选择器能够正确处理非颜色方案颜色和其他 CSS 值，您必须始终使用 `dark-light-choose`，如 [Update themes and plugins to support automatic dark mode - #5 by pmusaraj](https://meta.discourse.org/t/update-themes-and-plugins-to-support-automatic-dark-mode/161595/5) 中所述。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2025年十二月14日 15:24 UTC](https://meta.discourse.org/t/dark-light-mode-toggle-delivers-mixed-results-when-os-settings-do-not-match-toggle-settings/386568/5 "2025-12-14T15:24:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
