Coding Challenge #3 - Toggle Switch
Key Takeaways
The video demonstrates a coding challenge to create a custom toggle switch using HTML and CSS, without JavaScript, by styling a checkbox input field.
Full Transcript
okay then my friends so in this challenge I'm gonna ask you to make a simple toggle switch just like this using a checkbox input field and some CSS so no JavaScript whatsoever just HTML and CSS now to begin with that's going to look something like this in a browser just an ordinary checkbox so what I want you to do is take this checkbox and make a toggle switch like this based on that checkbox now one thing to note it's not the check box itself that's being styled to make it look like this the checkbox is just there under the hood for the functionality of being checked as the actual form field when we toggle the switch on and off so when we toggle it on then the checkbox is essentially tipped and then when we toggle it off the check box becomes unticked and I can demonstrate that by revealing the checkbox itself using the dev tools which are on my other screen which is why you can't see them but now we can see the check box on the page and notice how when we toggle the switch the check box is getting toggled as well so you need to think about how that can work because without the checkbox itself this toggle right here is pretty meaningless the checkbox is the thing that gets updated in the background but it can be hidden by the CSS so I've prepped the starter files for you already and you can find those on the code challenges GitHub repo right here I'll leave the link to this down below the video and to download the starting code for this challenge go to The Challenge three star branch and then just hit the green code button and download a zip folder of this Branch once you've done that you can unzip the folder and open it up in a text editor so then in this starter project we've got just two files an index.html file and a styles.css file in the HTML file we're linking up to the CSS file in the head and inside the body we've got some simple HTML as well to get you started a div with a class of toggle and inside that a checkbox input and another div with a class of switch so this toggle div is just the toggle container to group everything together and this switch div is going to be the actual thing you style to make it look like a switch now if you want to completely change this HTML that's fine there's more than one way to approach this Challenge and likewise you might need to add some more HTML to this as well for everything to work now in the CSS we have just a simple body style giving the whole page a background of Gray and a root selector to register some CSS variables and on state color and an off State color and the toggle width and height values now you don't have to use these if you don't want to you can use whatever values that you want I just wanted to leave them here in case you did want to use them anyway that's pretty much it for the challenge have a good go at it and remember it's CSS and HTML only no JavaScript and if you do solve it feel free to link a solution Your solution Down Below in the comments good luck and I'm going to be back with my solution pretty soon
Original Description
Coding challenge 3 - try making a custom toggle switch.
🐱💻 Access the starter files on GitHub:
https://github.com/iamshaunjp/Coding-Challenges/tree/challenge-3-start
⭐⭐ Get access to all free & PREMIUM courses on Net Ninja Pro:
https://net-ninja-pro.teachable.com/p/net-ninja-pro/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
More on: HTML & CSS
View skill →Related Reads
📰
📰
📰
📰
The Minecraft anvil is a tree-cost optimization problem in disguise
Dev.to · Mark
KMP Algorithm (Knuth-Morris-Pratt): The Smart Way to Perform String Matching in O(N)
Dev.to · Jaspreet singh
Every Backtracking Problem Is the Same Three Lines. I Just Couldn't See the Tree.
Dev.to · Alex Mateo
DSA From Zero to Hero #3: Sliding Window (Fixed Size) Explained With a Java Example
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI