Firefox: How to test prefers-color-scheme?

十年热恋 提交于 2019-12-14 03:39:56

问题


In Firefox 67, one can use media queries to detect user preference on light or dark theme.

In my version of Firefox (under Ubuntu), it seems that my preference is light theme. That is, the following CSS gives a blue background:

@media (prefers-color-scheme: light) {
   :root {}
  body {
    background-color: blue;
  }
}

How can I change my Firefox preferences so that prefers-color-scheme: dark evaluates to true?

I found an add-on that seems to do the trick, but I must be doing something wrong with my own CSS, as it does not work on my page. Dark Website forcer


回答1:


You can update the style used by Firefox by going to about:config and adding a new property ui.systemUsesDarkTheme of integer type with value 1.

It doesn't automatically update the value on active pages in the same way that it does when you're updating OS settings in Windows or Mac, but if you refresh the page after updating it will pick up.

You can confirm the browser setting is correct by viewing the example on mdn

Edit: On firefox 71 the update is applied to active pages without refresh



来源:https://stackoverflow.com/questions/56401662/firefox-how-to-test-prefers-color-scheme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!