<button>Toggle Color</button>
<p>testtext</p>
<style>
html{
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
body {
background: grey;
}
}
@media (prefers-color-scheme: light) {
body {
background: yellow;
}
}
</style>
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// подключаем тёмную цветовую схему (dark-color.css)
}
:root {
--main-bg-color: brown;
}
:root {
--main-bg-color: tomato;
}
body {
background-color: var(--main-bg-color);
}
:root {
--main-bg-color: brown;
}
@media (prefers-color-scheme: dark) {
:root {
--main-bg-color: tomato;
}
}
body {
background-color: var(--main-bg-color);
}