我有部分 View ,我在 View 中使用
在这个partialView中我有切换开关
这是该开关的 css 文件
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {display:none;}
.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: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
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%;
}
这里是partialView中的代码,其中这个切换是
<div id="switcher" class="doctors-appointment">
<div class="Row">
<div class="Column">
<b>Doctor's appointment</b>
</div>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<div class="Column">
<b>For internal purposes</b>
</div>
</div>
</div>
我在该切换中遇到的问题是渲染效果很好,但是当我单击它时,它没有动画。
哪里会出问题?
感谢您的帮助。
最佳答案
这是与您的动画代码相同的片段。
看看这个片段,我认为还有其他 css
与您的开关 css
冲突。
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {display:none;}
.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: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
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%;
}
<div id="switcher" class="doctors-appointment">
<div class="Row">
<div class="Column">
<b>Doctor's appointment</b>
</div>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<div class="Column">
<b>For internal purposes</b>
</div>
</div>
</div>
关于jquery - 切换开关在 PartialView 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45521456/