# 如何根据深色或浅色模式更改 CSS 项？

**URL:** <https://meta.discourse.org/t/how-to-change-css-item-based-on-dark-or-light-mode/268631>\
**Category:** Development\
**Created:** [2023年六月16日 14:14 UTC](https://meta.discourse.org/t/how-to-change-css-item-based-on-dark-or-light-mode/268631 "2023-06-16T14:14:54Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2023年六月16日 14:21 UTC](https://meta.discourse.org/t/how-to-change-css-item-based-on-dark-or-light-mode/268631/2 "2023-06-16T14:21:26Z")

</div>

我怀疑这个话题可能会帮到你。

> [@Use color scheme color if dark scheme, otherwise use my color in theme](https://meta.discourse.org/t/use-color-scheme-color-if-dark-scheme-otherwise-use-my-color-in-theme/191365):
>
> I want to do something like this .some-link { @if var(--scheme-type) == 'dark' { color: var(--primary); } @else { color: #3b5998; } but of course it is not possible because there is no if in CSS and SCSS is not processed at runtime. And as far as I can see Discourse does not add any classes to indicate whether the dark scheme is active, and CSS does not allow custom properties in selectors. Any ideas what could be the best workaround?

---

_[View the full topic](https://meta.discourse.org/t/how-to-change-css-item-based-on-dark-or-light-mode/268631)._
