Ночной и дневной режим вопрос
Имейте следующий код, пытаясь заставить его взять и остаться в ночном или дневном режиме в зависимости от того, что нажимается для всего сайта или если страница обновляется
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Day And Night Mode</title> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <style> body { margin: 0; padding: 0; font-family: sans-serif; } section { position: absolute; top: 0; left: 0; width: 100%; height: 100vh; box-sizing: border-box; padding: 100px; transition: 0.5s; } section.dark { background: #262626; color: #fff; } ul { position: absolute; top: 20px; right: 20px; margin: 0; padding: 0; width: 100px; height: 30px; z-index: 1; border: 1px solid #000; border-radius: 4px; cursor: pointer; overflow: hidden; } ul.active { border-color: #fff; } ul li { list-style: none; width: 100%; height: 60px; text-align: center; text-transform: uppercase; transition: 0.5s; } ul.active li { transform: translateY(-30px); } ul li span { display: block; width: 100%; height: 30px; line-height: 30px; color: #262626; background: #fff; } ul li span:nth-child(1) { background: #262626; color: #fff; } </style> <section> <h1>What is Lorem ipsum ?</h1> <p>"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p> <p>"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p> <p>"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p> </section> <ul> <li> <span>Night</span> <span>Light</span> </li> </ul> <script src="https://code.jquery.com/jquery-3.3.1.js"></script> <script type="text/javascript"> $(document).ready(function() { $('ul').click(function() { $('ul').toggleClass('active') $('section').toggleClass('dark') }) }) </script> </body> </html>
Что я уже пробовал:
пробовал играть с java но не смог понять как держать настройки для обновления и или всего сайта в зависимости от того в каком режиме вы находитесь заранее спасибо
Afzaal Ahmad Zeeshan
Вы хотите сохранить состояние приложения в темном или светлом режиме?
Reddog2
Я хочу взять и установить эту штуку туда, где если кто-то нажимает кнопку Night и переходит на другую страницу на сайте, то он берет и держит темный режим или если нажимается ночной режим и страница обновляется, почему в ночном режиме он держит ночной режим на обновлении. Надеюсь, это поможет. Я видел на некоторых сайтах, когда гуглил его, что некоторые люди говорят что-то о команде Onload и т. д. ???