Toggle Buttton
How do I make an toggle buttton?
What is a toggle buttton? How do you make a toggle buttton? This script and codes were developed by Juwan Petty on 12 October 2022, Wednesday.
Toggle Buttton - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Toggle Buttton</title> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="toggle"> <i class="material-icons scale-up-icon" id="on">alarm_on</i> <div class="toggle-btn"> <div class="toggle-btn-circle"></div> </div> <i class="material-icons" id="off">alarm_off</i>
</div> <script src="js/index.js"></script>
</body>
</html>
Toggle Buttton - Script Codes CSS Codes
html, body { height: 100%; width: 100%; display: flex; justify-content: center; align-items: center; background: #FAFAFA;
}
body { transition: 300ms;
}
.toggle { display: flex; justify-content: center; align-items: center;
}
i { opacity: 0.54;
}
.toggle-btn { background: #76F7BF; height: 50px; width: 100px; border-radius: 50px; margin: 0 20px; cursor: pointer; transition: 300ms;
}
.toggle-btn-circle { height: 46px; width: 46px; background: #5FDD9D; position: relative; top: 1.5px; left: 2px; display: inline-block; opacity: 1; border-radius: 25px; transition: 300ms;
}
.material-icons { transition: 300ms;
}
.scale-up-icon { transform: scale(1.5);
}
@keyframes option-left { from { left: 2px } to { left: 51px }
}
@keyframes option-left-reverse { to { left: 2px } from { left: 51px }
}
Toggle Buttton - Script Codes JS Codes
var count = 0;
$(document).ready(function() { $('.toggle-btn').click(function() { if (count == 0) { $('.toggle-btn-circle').css("animation", "option-left 150ms ease-in-out 0s 1 forwards"); $('#off').addClass('scale-up-icon'); $('#on').removeClass('scale-up-icon'); $('.toggle-btn').css("background", "#F3F3F3"); $('.toggle-btn-circle').css("background", "#C1C1C1"); count = 1; } else if (count == 1) { $('.toggle-btn-circle').css("animation", "option-left-reverse 150ms ease-in-out 0s 1 forwards"); $('#off').removeClass('scale-up-icon'); $('#on').addClass('scale-up-icon'); $('.toggle-btn').css("background", "#76F7BF"); $('.toggle-btn-circle').css("background", "#5FDD9D"); count = 0; } });
});
Developer | Juwan Petty |
Username | juwanpetty |
Uploaded | October 12, 2022 |
Rating | 3 |
Size | 2,227 Kb |
Views | 16,192 |
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 |
Flexbox Card Layout | 2,351 Kb |
Flexbox Split Screen | 1,934 Kb |
Simple Navigation Bar | 2,589 Kb |
Udacity Button Style | 2,186 Kb |
A CSS Menu Toggle using jQuery | 2,716 Kb |
A Pen by Juwan Petty | 4,097 Kb |
A Fun Little Button | 2,388 Kb |
Animated Random Phrase | 2,662 Kb |
Design Method for Perfect Padding | 1,861 Kb |
Simple Button Animation | 1,754 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 |
Comparison of Roboto Draft vs Roboto | Jxnblk | 2,880 Kb |
Default Input, Textareas, Submits, and Buttons in iOS | Demersdesigns | 2,334 Kb |
Countdown Timer | Massiebn | 3,001 Kb |
Vue.js Starter | Andymerskin | 1,268 Kb |
STIKHOI | Denmch | 7,122 Kb |
SVG Animation | Pollardld | 3,133 Kb |
We Simplify animation | Meodai | 48,169 Kb |
Two Element Typeface | Chrisota | 4,942 Kb |
A Pen by Manoz | Manoz | 2,424 Kb |
Slide like Mailbox | Hmps | 3,758 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!