【发布时间】:2018-10-11 14:45:08
【问题描述】:
我在 angular4 环境中使用它,所以害怕使用 jquery,这是我的 HTML 和 CSS:
<div class="row"> <input type="text"></div>
<div class="row"> <input type="text"></div>
<div class="row"> <input type="text"></div>
<div class="row"> <label class="switch">
<input type="checkbox" checked>
<span class="slider round"></span>
</label></div>
<div class="row"> <input type="text"></div>
<div class="row"> <input type="text"></div>
<div class="row"> <input type="text"></div>
.row{
padding:15px;
}
.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);
}
以下是此代码工作的 URL: https://plnkr.co/edit/eVX3ATeizyuTIkqzmG94?p=preview
在切换之前我有一些输入,所有输入都可以使用 Tab 键选择,但切换按钮会被跳过。
焦点后,我需要在箭头上移动此切换按钮按激活/停用
或者我们如何使用键盘选择复选框。
【问题讨论】:
-
请提供您的组件的完整 html 代码。不看全貌就很难理解你的问题