switch-final.txt
HTML document, ASCII text
1<!DOCTYPE html> 2<html> 3 4<head> 5<style> 6:root { 7background: #000; 8color: #fff; 9} 10input[type=checkbox].switch { 11-webkit-appearance: none; 12-moz-appearance: none; 13appearance: none; 14position: relative; 15background: #fff; 16width: 30px; 17height: 16px; 18} 19input[type=checkbox].switch::before { 20top: 1px; 21left: 1px; 22position: absolute; 23display: block; 24background-color: #ff5c1c; 25content: ""; 26width: 14px; 27height: 14px; 28transition: background-color .5s, left .5s; 29} 30input[type=checkbox].switch:checked::before { 31left: 15px; /* .switch width - .switch::before width - 1px */ 32background-color: #3f9b00; 33} 34</style> 35</head> 36 37<body> 38<input type="checkbox" class="switch" /> 39</body> 40 41</html>