So I've added a dark mode theme that I can turn on with a click of a button. A have a javascript that changes the stylesheet with a press of a button:
function nightmode(sheet,sheet2) {
document.getElementById('light1').setAttribute('href', sheet);
document.getElementById('light2').setAttribute('href', sheet2);
}
And buttons which can change the stylesheet
<li> <a onclick="nightmode('/cdn/about/css/main_dark.css','/cdn/about/css/bootstrap_dark.css')" alt="nightmode"> <i class="far fa-moon "></i> </a></li>
<li> <a onclick="nightmode('/cdn/about/css/main.css','/cdn/about/css/bootstrap.css')" alt="nightmode"> <i class="fas fa-moon "></i> </a></li>
But the problem is when I click one of the button the stylesheet changes size of different elements, for example my icon on the website changes. This can be tested on https://swedcraft.net/Game_Hub/ by pressing on the moons. The difference between the two stylesheets are only colors, no sizes. Thank you!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.