.checkbox{ display: inline-block; } .checkbox input[type=checkbox]{ margin: 0; visibility: hidden; left: 1px; top: 1px; } .checkbox label{ width: 20px; height: 40px; border: 2px solid #706d92; cursor: pointer; border-radius: 100px; overflow: hidden; display: block; position: relative; z-index: 1; transition: all 0.3s ease; } .checkbox label:before{ content: ''; background: #706d92; border-radius: 50px; width: 16px; height: 16px; transform: translateX(-50%); position: absolute; bottom: 2px; left: 50%; transition: all 0.3s ease; } .checkbox input[type=checkbox]:checked+label{ background: #7338ba; border: 2px solid #7338ba; } .checkbox input[type=checkbox]:checked+label:before{ background: #fff; bottom: 18px; } @media only screen and (max-width:767px){ .checkbox{ margin: 0 0 20px; } }