Single-element Toggle Switch
How do I make an single-element toggle switch?
Just another toggle switch.. What is a single-element toggle switch? How do you make a single-element toggle switch? This script and codes were developed by Keith Pickering on 10 August 2022, Wednesday.
Single-element Toggle Switch - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Single-element Toggle Switch</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ *, *:before,
*:after { box-sizing: border-box;
}
html { font-family: 'Roboto Condensed', sans-serif; display: flex; justify-content: center; align-items: center; text-align: center; height: 100%; color: #ECEFF1; background-image: radial-gradient(#4f6875, #263238);
}
.toggle { position: relative; display: block; margin: 0 auto; width: 150px; height: 60px; color: white; outline: 0; text-decoration: none; border-radius: 100px; border: 2px solid #546E7A; background-color: #263238; transition: all 500ms;
}
.toggle:active { background-color: #1c2429;
}
.toggle:hover:not(.toggle--moving):after { background-color: #455A64;
}
.toggle:after { display: block; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); line-height: 45px; text-align: center; text-transform: uppercase; font-size: 20px; color: white; background-color: #37474F; border: 2px solid; transition: all 500ms;
}
.toggle--on:after { content: 'On'; border-radius: 50px 5px 5px 50px; color: #66BB6A;
}
.toggle--off:after { content: 'Off'; border-radius: 5px 50px 50px 5px; transform: translate(100%, 0); color: #f44336;
}
.toggle--moving { background-color: #1c2429;
}
.toggle--moving:after { color: transparent; border-color: #435862; background-color: #222c31; transition: color 0s, transform 500ms, border-radius 500ms, background-color 500ms;
}
h1 { font-size: 64px; margin-top: 0; margin-bottom: 50px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300' rel='stylesheet' type='text/css'>
<h1>Toggle.</h1>
<a href="#" class="toggle toggle--on"></a> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Single-element Toggle Switch - Script Codes CSS Codes
*, *:before,
*:after { box-sizing: border-box;
}
html { font-family: 'Roboto Condensed', sans-serif; display: flex; justify-content: center; align-items: center; text-align: center; height: 100%; color: #ECEFF1; background-image: radial-gradient(#4f6875, #263238);
}
.toggle { position: relative; display: block; margin: 0 auto; width: 150px; height: 60px; color: white; outline: 0; text-decoration: none; border-radius: 100px; border: 2px solid #546E7A; background-color: #263238; transition: all 500ms;
}
.toggle:active { background-color: #1c2429;
}
.toggle:hover:not(.toggle--moving):after { background-color: #455A64;
}
.toggle:after { display: block; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); line-height: 45px; text-align: center; text-transform: uppercase; font-size: 20px; color: white; background-color: #37474F; border: 2px solid; transition: all 500ms;
}
.toggle--on:after { content: 'On'; border-radius: 50px 5px 5px 50px; color: #66BB6A;
}
.toggle--off:after { content: 'Off'; border-radius: 5px 50px 50px 5px; transform: translate(100%, 0); color: #f44336;
}
.toggle--moving { background-color: #1c2429;
}
.toggle--moving:after { color: transparent; border-color: #435862; background-color: #222c31; transition: color 0s, transform 500ms, border-radius 500ms, background-color 500ms;
}
h1 { font-size: 64px; margin-top: 0; margin-bottom: 50px;
}
Single-element Toggle Switch - Script Codes JS Codes
$('.toggle').click(function(e) { var toggle = this; e.preventDefault(); $(toggle).toggleClass('toggle--on') .toggleClass('toggle--off') .addClass('toggle--moving'); setTimeout(function() { $(toggle).removeClass('toggle--moving'); }, 200)
});
Developer | Keith Pickering |
Username | keithpickering |
Uploaded | August 10, 2022 |
Rating | 4.5 |
Size | 3,875 Kb |
Views | 28,336 |
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 |
Lovely Transforming Menu Button | 11,445 Kb |
Windows 10 Concept | 16,180 Kb |
Text Inputs with Sliding Labels | 2,892 Kb |
Material Inspired Menu | 4,237 Kb |
Sliding Navigation Menu | 3,440 Kb |
Delicious SASS Buttons | 8,496 Kb |
Smooth, Semantic Tab Box | 4,256 Kb |
CSS Business Card | 185,152 Kb |
Metro Interactive Live Tiles | 5,953 Kb |
Easy Container-Breaking Sidebar | 4,673 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 |
This in constructor context | _shree33 | 1,718 Kb |
Loading animation with css | Icebob | 2,947 Kb |
Canvas Fireworks | Jackrugile | 6,200 Kb |
Importable Clearfix | Corysimmons | 1,411 Kb |
Freecodecamp - Tribute Page | Samoht513 | 3,583 Kb |
Tab panels | Accessibility | 0 Kb |
Filtering with shuffle.js | Deyand | 2,712 Kb |
TinFoil Boats | Chandralil | 4,577 Kb |
Glitchy Text Effect | Kescoe | 2,208 Kb |
SVG email test v2.0 | M_J_Robbins | 2,090 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!