Vanilla CSS Switcher

Developer
Size
2,296 Kb
Views
24,288

How do I make an vanilla css switcher?

Just HTML and CSS. No JS and animations. Idea by Artem Shykov.. What is a vanilla css switcher? How do you make a vanilla css switcher? This script and codes were developed by Maxim Konoval on 31 December 2022, Saturday.

Vanilla CSS Switcher Previews

Vanilla CSS Switcher - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Vanilla CSS Switcher</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="global_wrapper">	<div class="switcher_wrapper">	<input id="switcher" type="checkbox" name="switcher">	<label for="switcher" class="switcher_checkbox">	<span>Vanilla CSS Switcher</span>	<span class="checker">	<span class="checker_short-line"></span>	<span class="checker_long-line"></span>	</span>	</label>	</div>
</div> <script src="js/index.js"></script>
</body>
</html>

Vanilla CSS Switcher - Script Codes CSS Codes

body {	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;	font-size: 18px;	line-height: 24px;
}
.global_wrapper {	width: 99vw;	min-height: calc(100vh - 25px);	display: flex;	justify-content: center;	align-items: center;
}
.switcher_wrapper { width: 100%; max-width: 340px; height: 50px;
}
#switcher { position: absolute; opacity: 0; z-index: -1; visibility: hidden;
}
.switcher_checkbox { display: flex; justify-content: space-between; align-items: center; width: 100%; height: 100%; padding-right: 15px; padding-left: 15px; cursor: pointer; color: #000; background-color: #f6f8f9; border: 1px solid #dadfe3; border-radius: 30px; transition: all .25s ease;
}
#switcher:checked + .switcher_checkbox { color: #fff; background-color: #05c096;
}
.checker { position: relative; width: 30px; height: 30px; background-color: #fff; border: 1px solid #dadfe3; border-radius: 100%; transition: all .25s ease;
}
#switcher:checked + .switcher_checkbox,
#switcher:checked + .switcher_checkbox .checker { border-color: transparent;
}
.checker_short-line,
.checker_long-line { position: absolute; overflow: hidden; height: 3px; background-color: transparent; transform-origin: left;
}
.checker_short-line { top: 11px; left: 6px; width: 10px; transform: rotate(44.5deg);
}
.checker_long-line { top: 19px; left: 12px; width: 17px; transform: rotate(-45deg);
}
.checker_short-line::before,
.checker_long-line::before { content: ""; position: absolute; width: 100%; height: 100%; background-color: #05c096; transform: translateX(-110%); transform-origin: left; transition: all .15s ease;
}
#switcher:checked + .switcher_checkbox .checker_short-line::before,
#switcher:checked + .switcher_checkbox .checker_long-line::before { transform: translateX(0);
}
.checker_long-line::before,
#switcher:checked + .switcher_checkbox .checker_short-line::before { transition-delay: 0s;
}
.checker_short-line::before,
#switcher:checked + .switcher_checkbox .checker_long-line::before { transition-delay: .12s;
}

Vanilla CSS Switcher - Script Codes JS Codes

// Just don't need it
Vanilla CSS Switcher - Script Codes
Vanilla CSS Switcher - Script Codes
Home Page Home
Developer Maxim Konoval
Username Said_FD
Uploaded December 31, 2022
Rating 3
Size 2,296 Kb
Views 24,288
Do you need developer help for Vanilla CSS Switcher?

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!

Maxim Konoval (Said_FD) Script Codes
Create amazing blog posts with AI!

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!