# CSS 导致无法添加暗色主题

**URL:** https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637
**Category:** Development
**Tags:** css
**Created:** [2023年十一月26日 16:51 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637 "2023-11-26T16:51:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sunjam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sunjam/32/175682_2.png) [@sunjam](https://meta.discourse.org/u/sunjam)
#### Post date: [2023年十一月26日 16:51 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/1 "2023-11-26T16:51:36Z")

</div>

我在生产论坛上添加深色主题时遇到了困难。我不确定为什么，但网站的某些元素仍然是白色的。我在测试 Discourse 中无法重现此问题，但在启用深色主题后，生产论坛上的显示效果如下：

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/0/b/80be888758b469ebc8cf7fefff6d1261441f4ebe.png)

> **CSS。点击查看**
>
> .page-not-found-search { display: none; }  
> .hamburger-panel ul.category-links li.subcategory {  
> display: none;  
> }  
> img[src\*=‘#left’] {  
> float: left;  
> }  
> img[src\*=‘#right’] {  
> float: right;  
> }  
> img[src\*=‘#center’] {  
> display: block;  
> margin: auto;  
> }  
> .d-header-icons .icon:hover, .d-header-icons .icon:focus {  
> background-color: white;  
> }
> 
> .d-header-icons .d-icon {  
> color: white;  
> }
> 
> .d-header-icons .icon:hover .d-icon, .d-header-icons .icon:focus .d-icon {  
> color: #0082c9;  
> }
> 
> .drop-down-mode .d-header-icons .active .icon .d-icon {  
> color: #0082c9;  
> }
> 
> /\* 不在分类列表中显示子分类 \*/  
> .category-list .subcategories {  
> display: none;  
> }

据我所知，问题出在 CSS 上，所以我想知道如何更改它。感谢任何指导。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023年十一月26日 23:06 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/2 "2023-11-26T23:06:12Z")

</div>

还有其他主题或组件在起作用吗？

您是只更改配色方案还是尝试通过 CSS 进行更改？

可以分享网址吗？

---

<div class="post-metadata">

### Author: ![sunjam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sunjam/32/175682_2.png) [@sunjam](https://meta.discourse.org/u/sunjam)
#### Post date: [2023年十一月30日 15:39 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/3 "2023-11-30T15:39:04Z")

</div>

> [@pfaffman](#):
>
> 还有其他主题或组件在起作用吗？

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/1/7/11711577709e54c0e3c4f55ca3acb4636f4ffac5.png)

> [@pfaffman](#):
>
> 你只是在更改配色方案还是试图通过 CSS 进行更改？

到目前为止，我一直在调整配色方案。我已将现有的 CSS（上面链接）和主题设置导出到我的本地 discourse 中进行测试，但没有遇到任何麻烦。

> [@pfaffman](#):
>
> 可以分享一下网址吗？

据我所知，我为了获得这种级别的访问权限而放弃了这项特权。❤

---

<div class="post-metadata">

### Author: ![sunjam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sunjam/32/175682_2.png) [@sunjam](https://meta.discourse.org/u/sunjam)
#### Post date: [2023年十一月30日 18:05 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/4 "2023-11-30T18:05:24Z")

</div>

我弄明白了。在自定义组件中写入了额外的自定义 CSS 值，我以为它是默认的。删除该组件解决了所有问题，深色主题完美运行。

感谢您的指导@pfaffman，我知道大家生活都很忙。 ❤

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023年十一月30日 22:07 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/5 "2023-11-30T22:07:24Z")

</div>

我猜是“将横幅设为白色”！！！

---

<div class="post-metadata">

### Author: ![sunjam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sunjam/32/175682_2.png) [@sunjam](https://meta.discourse.org/u/sunjam)
#### Post date: [2023年十一月30日 22:08 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/6 "2023-11-30T22:08:05Z")

</div>

这是“字体” 😉

---

<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: [2023年十二月30日 22:09 UTC](https://meta.discourse.org/t/css-is-breaking-ability-to-add-dark-theme/286637/7 "2023-12-30T22:09:05Z")

</div>

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