【发布时间】:2026-01-07 21:35:02
【问题描述】:
我一直在关注仅使用 CSS3 设置复选框样式的教程,这就是我想出的:
演示:
http://cssdeck.com/labs/jaoe0azx
复选框的样式很好 - 但是当我通过表单控件进行选项卡时 -> 复选框被跳过。任何建议为什么?
HTML:
<form role="form" id="login_form" data-mode="login">
<div class="form-group">
<label for="ue">Username or email:</label>
<input type="email" class="form-control input-lg" name="ue" id="ue" placeholder="" />
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control input-lg" name="password" id="password" placeholder="" />
</div>
<div>
<input id="rememberme" type="checkbox" name="rememberme" value="1" class="checkbox_1" tabindex="0" />
<label for="rememberme" class="checkbox_1" tabindex="0">remember me</label>
</div>
<div id="auth_area_login_button">
<button class = "btn btn-lg btn-primary">
Login
</button>
</div>
</form>
CSS:
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css');
#login_form{padding:20px;}
label.checkbox_1 {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin: 0px;
}
label.checkbox_1:before {
content: "";
display: inline-block;
width: 16px;
height: 16px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 0px;
}
label.checkbox_1:hover:before{border-color:#66afe9;}
input[type=checkbox].checkbox_1 {
display: none;
}
input[type=checkbox].checkbox_1:checked + label.checkbox_1:before {
content: "\2713";
font-size: 15px;
color: #A0A0A0;
text-align: center;
line-height: 15px;
}
编辑1:
似乎可以在 Firefox 中工作,但不能在 chrome 中...
【问题讨论】:
-
您好,请在此处显示一些相关代码。谢谢! (Here's 为什么)
-
似乎在密码字段上按 tab 后获得焦点,至少在最新的 Firefox (26.0) 上,但我无法使用空格键检查它,就像在“正常”复选框中一样。跨度>
-
嗯。是的 - 在 Firefox 中工作,而不是 chrome...