<div class="switch">
			<input class="switch-checkbox" id="switchID1" type="checkbox" name="switch-checkbox">
			<label class="switch-label" for="switchID1">
				<span class="switch-txt" turnOn="開" turnOff="關"></span>
				<span class="switch-Round-btn"></span>
			</label>
		</div>
<hr>
		<div class="switch">
			<input class="switch-checkbox" id="switchID2" type="checkbox" name="switch-checkbox" checked>
			<label class="switch-label" for="switchID2">
				<span class="switch-txt" turnOn="開" turnOff="關"></span>
				<span class="switch-Round-btn"></span>
			</label>
		</div>
.switch {
  position: relative;
  width: 65px;
  height: 30px;
  line-height: 30px;
}
.switch-checkbox {
  display: none;
}

.switch-label {
  display: block;
  overflow: hidden;
  cursor: pointer;
  border-radius: 20px;
}

.switch-txt {
  display: block;
  width: 200%;
  margin-left: -100%;
  transition: margin 0.3s ease-in 0s;
}

.switch-txt::before,
.switch-txt::after {
  display: block;
  float: right;
  width: 50%;
  font-size: 13px;
  color: #fff;
  font-weight: bold;
  box-sizing: border-box;
}

.switch-txt::after {
  content: attr(turnOn);
  padding-left: 10px;
  background: #1ba0ef;
  color: #fff;
}

.switch-txt::before {
  content: attr(turnOff);
  padding-right: 10px;
  background: #eee;
  color: #ccc;
  text-align: right;
}

.switch-Round-btn {
  position: absolute;
  display: block;
  width: 26px;
  height: 26px;
  margin: 2px;
  background: #fff;
  top: 0;
  bottom: 0;
  right: 35px;
  border-radius: 13px;
  transition: all 0.3s ease-in 0s;
}

.switch-checkbox:checked + .switch-label .switch-txt {
  margin-left: 0;
}

.switch-checkbox:checked + .switch-label .switch-Round-btn{
  right: 0;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.