728x90
HTML
<script>
$(window).on('load', function(){
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
localStorage.theme = 'dark';
$('.theme-toggle button').html('โ๏ธ');
} else {
document.documentElement.classList.remove('dark');
localStorage.theme = 'light';
$('.theme-toggle button').html('๐');
}
$('.theme-toggle').on('click', ()=>{
if(localStorage.theme === 'dark')
{
document.documentElement.classList.remove('dark');
localStorage.theme = 'light';
$('.theme-toggle button').html('๐');
}
else
{
document.documentElement.classList.add('dark');
localStorage.theme = 'dark';
$('.theme-toggle button').html('โ๏ธ');
}
})
});
</script>
<div class="util">
<div class="theme-toggle">
<button type="button">๐</button>
</div>
</div>
CSS
/* ๋คํฌ๋ชจ๋ */
.dark body{
background-color: #161618 !important;
color: rgb(255, 255, 255) !important;
font-weight: 700 !important;
}
728x90
'๐ฅ๏ธํ๋ก ํธ์๋ > HTML | CSS | JAVASCRIPT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์๋ฐ์คํฌ๋ฆฝํธ - XPATH ๋ฌธ๋ฒ์ผ๋ก DOM ELEMENT ๊ฐ์ ธ์ค๊ธฐ (0) | 2023.11.12 |
---|---|
์๋ฐ์คํฌ๋ฆฝํธ - GET ํ๋ผ๋ฏธํฐ ์ถ์ถํ๊ธฐ (1) | 2023.10.26 |
์๋ฐ์คํฌ๋ฆฝํธ - ์๋ฐ์คํฌ๋ฆฝํธ ๋๋ ํ ์ฌ์ดํธ(obfuscator.io) (0) | 2023.09.05 |
CSS - ์ธ๊ธฐ ์๋ ๋์์ธ ํ๋ ์์ํฌ(Tailwind CSS) (0) | 2023.08.28 |
CSS - ๋ฏธ๋์ด์ฟผ๋ฆฌ ํ์ธ ์ฌ์ดํธ(mediaqueriestest.com) (0) | 2023.08.28 |