Search
 
SCRIPT & CODE EXAMPLE
 

CSS

CSS Toggle Switch

<div class="switch-toggle">
    <div class="button-check" id="button-check">
      <input type="checkbox" class="checkbox">
      <span class="switch-btn"></span>
      <span class="layer"></span>
    </div>
</div>

<style> 
* {
  padding: 0;
  margin: 0;
  outline: 0;
  font-family: 'IBM Plex Sans', sans-serif;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
.switch-toggle {
  display: flex;
  height: 100%;
  align-items: center;
}
.switch-btn, .layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.button-check {
  position: relative;
  width: 90px;
  height: 46px;
  overflow: hidden;
  border-radius: 50px;
  -webkit-border-radius: 50px;
  -moz-border-radius: 50px;
  -ms-border-radius: 50px;
  -o-border-radius: 50px;
}
.checkbox {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}

.switch-btn {
  z-index: 2;
}

.layer {
  width: 100%;
  background-color: #8cf7a0;
  transition: 0.3s ease all;
  z-index: 1;
}
#button-check .switch-btn:before, #button-check .switch-btn:after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 30px;
  height: 20px;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  line-height: 1;
  padding: 9px 4px;
  background-color: #00921c;
  border-radius: 50%;
  transition: 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15) all;
  display: flex;
  align-items: center;
  justify-content: center;
}

#button-check .switch-btn:before {
  content: 'ON';
}

#button-check .switch-btn:after {
  content: 'OFF';
}

#button-check .switch-btn:after {
  right: -50px;
  left: auto;
  background-color: #F44336;
}

#button-check .checkbox:checked + .switch-btn:before {
  left: -50px;
}

#button-check .checkbox:checked + .switch-btn:after {
  right: 4px;
}

#button-check .checkbox:checked ~ .layer {
  background-color: #fdd1d1;
}
</style>
Comment

PREVIOUS NEXT
Code Example
Css :: send element to center of div 
Css :: aspect ratio css media query 
Css :: animation background css 
Css :: color gradient 
Css :: how to change font size in css 
Css :: how to make a html css js editor 
Css :: can you control another div on hover css 
Css :: allfont cdn 
Css :: css width percentage 
Css :: vue scoped css child component 
Css :: choose grid position html 
Css :: How to make website responsive for safari 
Css :: liste commandes disponibles linux 
Css :: dot in image css 
Css :: javascript index value 
Css :: como hacer que me queden los nombres dentro de un formulario css 
Css :: placer balise p a la suite 
Css :: css change background color 
Css :: webkit-scrollbar-button css 
Css :: insert checkbox into combobox css 
Css :: build responsive real-world websites with html and css download 
Css :: ohmyzsh shortcut to oepn folder with vscode 
Css :: animation properties css 
Css :: css clamp vs media queries 
Css :: dark-mode 
Css :: background-clip 
Css :: Set cellpadding and cellspacing in CSS? 
Css :: css hover change other element 
Css :: target element pseudo-classes 
Css :: why grepper not always shows 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =