<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<style>
body{background: rgb(57, 179, 255)}
label {
display: block;
width: 70px;
height: 30px;
}
.mui-switch + .mui-switch-text {
width: 100%;
height: 100%;
border: 1px solid #fff;
background-color: transparent;
display: flex;
align-items: center;
position: relative;
}
.mui-switch-text:before {
content: '译';
width: 50%;
height: 100%;
top: 0;
left: 0;
position: absolute;
display: flex;
align-items: center;
justify-content: center;
color: rgb(57, 179, 255);
transition: left 0.2s;
background-color: #fff; }
.mui-switch:checked + .mui-switch-text:before {
content: '英';
left: 50%; }
.mui-switch + .mui-switch-text span {
display: inline-block;
width: 50%;
text-align: center;
color: #fff;
}
</style>
</head>
<body>
<label>
<input class="mui-switch" onclick="switchs(this)" type="checkbox" hidden>
<div class="mui-switch-text"><span>译</span><span>英</span></div>
</label>
<div class="text">false</div>
<script>
function switchs(dom){
document.querySelector('.text').innerText = dom.checked;
}
</script>
</body>
</html>