编辑
“切换/切换单选”输入按钮可在其他浏览器上使用,但不适用于IE。
忘记提及我正在从旧版本编辑现有标记 项目。我希望从CSS方面解决此问题并解决该问题,而无需修改标记 (波纹管),尽可能地使其在全球范围内使用。
<div class="input-icon">
<input type="checkbox" value="1" class="switch">
</div>
Please check my codes
https://codepen.io/vrsotto/pen/qGpzeE
答案 0 :(得分:0)
尝试使用下面的代码进行测试可能会帮助您解决Internet Explorer的问题。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: limegreen;
}
input:focus + .slider {
box-shadow: 0 0 1px limegreen;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
<h2>Toggle Switch</h2>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<label class="switch">
<input type="checkbox" checked>
<span class="slider round"></span>
</label>
</body>
</html>
IE 11中的输出: