“Mendeteksi mode gelap” Kode Jawaban

Mendeteksi mode gelap

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches

console.log(isDarkMode) // Result: True or False
Rich Rhinoceros

Mendeteksi mode gelap

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
Disgusted Dragonfly

Mendeteksi mode gelap

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').match;
Combative Centipede

Mendeteksi Sistem Mode Gelap

/* 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;
    }
}
Yellowed Yak

Mendeteksi Sistem Mode Gelap

/* Light mode */
@media (prefers-color-scheme: light) {
    body {
        background-color: white;
        color: black;
    }
}
flexflower

Jawaban yang mirip dengan “Mendeteksi mode gelap”

Pertanyaan yang mirip dengan “Mendeteksi mode gelap”

Lebih banyak jawaban terkait untuk “Mendeteksi mode gelap” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya