📜  检测系统暗模式 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:48.143000             🧑  作者: Mango

代码示例3
/* Light mode, Dark mode is below... 
Standard is registered on W3C in Media Queries Level 5:
https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme
*/

@media (prefers-color-scheme: light) {
    body {
        background-color: white;
        color: black;
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background-color: black;
        color: white;
    }
}