📜  检测暗模式 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:46.603000             🧑  作者: 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;
    }
}