"Dark mode"
Bootstrap 4.1.1 Snippet by SANTANU CHOWDHURY

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class="container"> <div class="row"> <h2>Toggle Dark/Light Mode</h2> <p>Click the button to toggle between dark and light mode for this page.</p> <a onclick="myFunction()"> <i onclick="myFunction2(this)" class="fa fa-sun-o"></i> </a> </div> </div>
body { padding: 25px; background-color: white; color: black; font-size: 25px; } h2{ color:#f00; } .dark-mode { background-color: black; color: white; } .dark-mode h2{ color:white; }
function myFunction() { var element = document.body; element.classList.toggle("dark-mode"); element.classList.toggle("dark-mode h2"); } function myFunction2(x) { x.classList.toggle("fa-moon-o"); }

Related: See More


Questions / Comments: