* { box-sizing: border-box; } $malibu: #59ADEB; $curious-blue: #193549; html, body { background-color: $malibu; color: #fff; text-align: center; } .checkbox { display: inline-block; margin-top: 10%; padding-left: 1.5rem; position: relative; transform: translateZ(0); } input[type="checkbox"] { -webkit-appearance: none; -moz-appearance: none; background: none; border: 2px solid #fff; border-radius: 0; height: 1.125rem; left: 0; position: absolute; top: 0; width: 1.125rem; &:focus { border-color: $curious-blue; outline: 0; } &.checkmark { animation: checkmark-shrink 0.14s ease-out forwards; border-width: 0 2px 2px 0; transform: rotate(45deg); } &.box { animation: box-expand 0.14s ease-out forwards; } &:checked { border-color: $curious-blue; border-width: 0 2px 2px 0; left: 6px; height: 1.3125rem; transform: rotate(45deg); top: -4px; width: 0.625rem; &.box { animation: box-shrink 0.14s ease-out forwards; border: 2px solid; } &.checkmark { animation: checkmark-expand 0.14s ease-out forwards; border-width: 0 2px 2px 0; } } } @keyframes box-shrink { 0% { transform: rotate(0deg); top: 0px; left: 0px; width: 18px; height: 18px; } 100% { transform: rotate(45deg); top: 13px; left: 5px; width: 4px; height: 4px; } } @keyframes checkmark-expand { 0% { transform: rotate(45deg); top: 13px; left: 5px; width: 4px; height: 4px; } 100% { transform: rotate(45deg); top: -4px; left: 6px; width: 10px; height: 21px; border-right-width: 2px; border-bottom-width: 2px; } } @keyframes checkmark-shrink { 0% { top: -4px; left: 6px; width: 10px; height: 21px; border-right-width: 2px; border-bottom-width: 2px; } 100% { top: 13px; left: 5px; width: 4px; height: 4px; } } @keyframes box-expand { 0% { transform: rotate(45deg); top: 13px; left: 5px; width: 4px; height: 4px; } 100% { transform: rotate(0deg); top: 0px; left: 0px; width: 18px; height: 18px; } }