Html
    Css
    Js

    
                        
.wrap {
	width:42px;
	height:20px;
}
input {
	display:none;
}
label {
	display:block;
	border:1px solid #888;
	height:20px;
	border-radius:15px;
	transition:.3s;
}
label .move {
	display:block;
	width:20px;
	height:20px;
	border-radius:50%;
	box-shadow:1px 1px 1px #ccc;
	background:#fff;
	transition:.3s;
	overflow:hidden;
}
input:checked+label {
	background:red;
}
input:checked+label .move {
	transform:translateX(20px);
	box-shadow:none;
}
.move span {
	width:40px;
	display:block;
	height:20px;
	line-height:20px;
	transition:0.3s;
}
input:checked+label .move span {
	transform:translateX(-20px);
}
em {
	text-align:center;
	width:50%;
	font-size:12px;
	font-style:normal;
	float:left;
}

                        
↑上面代码改变,会自动显示代码结果 jQuery调用版本:1.11.3
 立即下载

有文字的开关按钮

1
      jiyahua0
      2019/7/11 17:17:05