You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To style elements based on color scheme preferences, use the prefers-color-scheme media query. The example below opts in the entire page to using both light and dark operating system color schemes via the color-scheme property, and then uses prefers-color-scheme to specify the desired foreground and background colors for individual elements in those color schemes.
看 neatcss 的时候,看到一个没见过的 CSS
Note
The
color-scheme
CSS property allows an element to indicate which color schemes it can comfortably be rendered in.Note
Styling based on color schemes
To style elements based on color scheme preferences, use the
prefers-color-scheme
media query. The example below opts in the entire page to using both light and dark operating system color schemes via thecolor-scheme
property, and then usesprefers-color-scheme
to specify the desired foreground and background colors for individual elements in those color schemes.这里写的是有点误导的,使用
@media (prefers-color-scheme: light)
和@media (prefers-color-scheme: dark)
并不依赖color-scheme: light dark;
这个的声明注释掉
color-scheme: light dark;
prefers-color-scheme
的媒体查询依然可以工作像使用了 light-dark() 能力的会依赖 color-scheme
比如 chrome 默认插入的样式
user agent stylesheet
如何测试?
The text was updated successfully, but these errors were encountered: