Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dark Theme code #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions Dark-Theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
🆂🆃🅴🅿🆂 🆃🅾 🅲🆁🅴🅰🆃🅴 🅳🅰🆁🅺/🅻🅸🅶🅷🆃 🅼🅾🅳🅴:


•Create an HTML Document.
•Create CSS for the document file as well as for dark mode.
•Add a switch/toggler to toggle between light and dark mode.
•Add functionality to the switch/toggler to toggle between light and dark mode using javascript or jQuery code.


# The following repository demonstrate switching between light and dark mode using JQuery code. It basically works by using functions hasClass(), addClass() and removeClass() method.

.
•𝙃𝙩𝙢𝙡 𝘾𝙤𝙙𝙚 𝙛𝙤𝙧 𝘿𝙖𝙧𝙠 𝙏𝙝𝙚𝙢𝙚•

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport"

content="width=device-width, initial-scale=1.0">

<title>Dark Mode</title>



<script src=

"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js">

</script>



<style>

body{

padding:10% 3% 10% 3%;

text-align:center;

}

img{

height:140px;

width:140px;

}

h1{

color: #32a852;

}

.mode {

float:right;

}

.change {

cursor: pointer;

border: 1px solid #555;

border-radius: 40%;

width: 20px;

text-align: center;

padding: 5px;

margin-left: 8px;

}

.dark{

background-color: #222;

color: #e6e6e6;

}

</style>

</head>



<body>

<div class="mode">

Dark mode:

<span class="change">OFF</span>

</div>



<div>

<h1>GeeksforGeeks</h1>



<p><i>A Computer Science Portal for Geeks</i></p>



<h3>Light and Dark Mode</h3>



<img src=

"https://media.geeksforgeeks.org/wp-content/uploads/20200122115631/GeeksforGeeks210.png">



<p>

Click on the switch on top-right

to move to dark mode.

</p>



</div>



<script>

$( ".change" ).on("click", function() {

if( $( "body" ).hasClass( "dark" )) {

$( "body" ).removeClass( "dark" );

$( ".change" ).text( "OFF" );

} else {

$( "body" ).addClass( "dark" );

$( ".change" ).text( "ON" );

}

});

</script>

</body>



</html>