Light Switch - Solution
How do I make an light switch - solution?
Repurposed and ReJS'd from from Thomas Kimura's Pen Toggle Buttons.. What is a light switch - solution? How do you make a light switch - solution? This script and codes were developed by Matthew Nahmias on 27 December 2022, Tuesday.
Light Switch - Solution - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Light Switch - Solution</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="wrapper"> <h1 class="title">Light Switch Solution</h1> <div id="toggle" class="toggle"> <input type="checkbox" class="check"> <div id="lightSwitch" class="switch lightSwitch"></div> <div class="track lightTrack"></div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>
Light Switch - Solution - Script Codes CSS Codes
body{ position:absolute; height:100%; width:100%; margin:0px; font-size:16px; line-height:1.5em; font-family: Franklin Gothic Medium, Franklin Gothic, ITC Franklin Gothic, Arial, sans-serif; text-align: center; transition: all .5s cubic-bezier(.95, .25, .30, .65);
}
.off{ background-color: #000;
}
.wrapper{ position:relative; height:50%; width:100%;
}
.title{ font-weight:300; color: #000;
}
.lightSwitch{ background:#fff;
}
.lightTrack{ background:#cecece;
}
.toggle{ position:absolute; width:100px; height:50px; top:50%; left:0; right:0; margin:0 auto; text-align:center; z-index:1; border-radius:100px;
}
.check{ height:100%; width:100%; border-radius:50%; cursor:pointer; opacity:0; margin:0px; z-index:2;
}
.switch{ position:absolute; top:5px; left:5px; height:40px; width:40px; border-radius:40px; z-index:-1; transition: all 0.5s cubic-bezier(.95, .25, .30, .65);
}
.track{ position:absolute; top:0px; left:0px; width:100%; height:100%; border-radius:50px; z-index:-2; transition: all 0.5s cubic-bezier(.95, .25, .30, .65);
}
.light{ position:absolute; top:-30px; left:0; right:0; margin:0 auto; width:10px; height:10px; border-radius:10px; transition: all 0.5s cubic-bezier(.95, .25, .30, .65);
}
.move{ transform: translate(50px); background:#2ecc71;
}
.move + .track{ background:#fff;
}
Light Switch - Solution - Script Codes JS Codes
// Store the toggle and lightswitch elements in variables
var toggle = document.getElementById('toggle');
var lightSwitch = document.getElementById('lightSwitch');
// Toggle the off class on the body and the move class on the lightswitch
function backgroundToggle(){ document.body.classList.toggle('off'); lightSwitch.classList.toggle('move');
}
// Create an event listener that watches for a click on the toggle element and runs the backgroundToggle function
toggle.onclick = backgroundToggle;
Developer | Matthew Nahmias |
Username | mnahmias |
Uploaded | December 27, 2022 |
Rating | 3 |
Size | 2,333 Kb |
Views | 10,120 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Bus Animation | 5,854 Kb |
Array Manipulation Example | 2,007 Kb |
Madlib Game - Exercise | 2,068 Kb |
Content Replacement - Solution | 1,935 Kb |
Array challenge | 2,123 Kb |
Content Replacement - Exercise | 1,828 Kb |
Click Event - Solution | 1,956 Kb |
Madlib Game - Solution | 2,258 Kb |
Hover Cards | 4,545 Kb |
Travel Preloader | 4,014 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Project_one | MOHIM | 9,592 Kb |
Responsive Pricing Table | Jeremycaris | 2,690 Kb |
Multiple jCarousel | Pafnuty | 2,461 Kb |
Blog Concept 2 | JGallardo | 2,994 Kb |
BenU Maintenance Site | Ksherman | 4,893 Kb |
Animate a paper plane along an SVG path, looking ahead | PotatoDie | 3,734 Kb |
A Pen by Matt Popovich | Mpopv | 3,349 Kb |
JQuery FullScreen Overlay | _codemics | 2,252 Kb |
SVG Circle Progress | JMChristensen | 3,368 Kb |
A Pen by Jason Kinney | Jason-kinney | 1,980 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!