WEBLEB
Home
AI Editor
Login
Pro
English
English
Français
Español
Português
Deutsch
Italiano
हिंदी
Minecraft Switch V.2
1831
Andev.web
Open In Editor
Video
Publish Your Code
0
Recommended
26 June 2024
Plane Switch
24 July 2025
CSS Toggle Switch HTML Code
9 July 2025
UI Theme Switcher: Light, Dark, Dim Options
HTML
Copy
Document
CSS
Copy
body { background-color: #212121; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .switch { font-size: 30px; position: relative; display: inline-block; width: 4em; height: 0.3em; } /* Hide default HTML checkbox */ .switch input { opacity: 1; width: 0; height: 0; } /* The slider */ .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #900c3f; transition: 0.4s; } .off { position: absolute; content: ""; height: 2em; width: 2em; background-color: white; transition: 0.4s; image-rendering: pixelated; opacity: 1; left: 0; bottom: -0.8em; } .on { position: absolute; content: ""; height: 2em; width: 2em; background-color: white; transition: 0.4s; image-rendering: pixelated; opacity: 0; left: 0; bottom: -0.8em; } .switch input:checked + .slider { background-color: #c70039; } .switch input:focus + .slider { box-shadow: 0 0 1px #c70039; } .switch input:checked ~ .off { transform: translateX(2em); } .switch input:checked ~ .on { transform: translateX(2em); opacity: 1; box-shadow: 0 0 10px 5px rgba(185, 178, 42, 0.919), 0 0 20px 10px rgba(199, 186, 0, 0.3), 0 0 30px 15px rgba(199, 0, 57, 0.1); }
JS
Copy
//This code does not need javascript:)