.toggle { position: relative; display: block; margin: 0 auto; width: 7.5rem; height: 2.8rem; color: white; outline: 0; text-decoration: none; border-radius: 8rem; border: 2px solid #546e7a; background-color: #263238; -webkit-transition: all 500ms; -moz-transition: all 500ms; -o-transition: all 500ms; transition: all 500ms; } .toggle:active { background-color: #1c2429; } .toggle:hover:not(.toggle--moving):after { background-color: #455a64; } .toggle:after { display: block; position: absolute; top: 3px; bottom: 3px; /* left: 4px; */ width: calc(50% - 4px); line-height: 2.12rem; height: 2.12rem; text-align: center; text-transform: uppercase; font-size: 20px; color: white; background-color: #37474f; border: 2px solid; -webkit-transition: all 500ms; -moz-transition: all 500ms; -o-transition: all 500ms; transition: all 500ms; } .toggle--on:after { content: "On"; border-radius: 50px 5px 5px 50px; color: #66bb6a; left: 4px; } .toggle--off:after { content: "Off"; border-radius: 5px 50px 50px 5px; color: #f44336; left: -4px; -webkit-transform: translate(100%, 0); -moz-transform: translate(100%, 0); -o-transform: translate(100%, 0); transform: translate(100%, 0); } .toggle--moving { background-color: #1c2429; } .toggle--moving:after { color: transparent; border-color: #435862; background-color: #222c31; -webkit-transition: color 0s, transform 500ms, border-radius 500ms, background-color 500ms; -moz-transition: color 0s, transform 500ms, border-radius 500ms, background-color 500ms; -o-transition: color 0s, transform 500ms, border-radius 500ms, background-color 500ms; transition: color 0s, transform 500ms, border-radius 500ms, background-color 500ms; } @media (max-width: 1366px) { .toggle:after { top: 3px; top: 3px; } } @media (min-width: 1920px) { .toggle:after { top: 5px; top: 5px; } }