【发布时间】:2015-06-11 06:06:14
【问题描述】:
我正在使用 bootstrap 3 和另一个 css 模板。我想使用模板对复选框进行样式化,但它不起作用,因为我无法使用输入区域。当我单击它时,什么都没有出现。 这是代码:
HTML:
<div class="checkbox check-primary ">
<input type="checkbox" value="">
<label>Guardar usuario</label>
</div>
CSS:
.checkbox {
display: block;
min-height: 20px;
vertical-align: middle;
}
.checkbox input[type=checkbox] {
display: none;
}
.checkbox label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
margin-bottom: 6px;
color: #777a80;
transition: border 0.2s linear 0s,color 0.2s linear 0s;
}
.checkbox label:before {
content: "";
display: inline-block;
width: 17px;
height: 17px;
margin-right: 10px;
position: absolute;
left: 0px;
top: 1.4px;
background-color: #fff;
border: 1px solid #c2c6cb;
border-radius: 3px;
transition: border 0.2s linear 0s,color 0.2s linear 0s;
}
.checkbox input[type=checkbox]:checked + label::after {
font-family: 'FontAwesome';
content: "\F00C";
}
.checkbox label::after {
display: inline-block;
width: 16px;
height: 16px;
position: absolute;
left: 3.2px;
top: 0px;
font-size: 11px;
transition: border 0.2s linear 0s,color 0.2s linear 0s;
}
就是这样。该复选框仅在我退出此规则时运行: .checkbox 输入[type=checkbox] { 显示:无; }
如果我有很多错误,请耐心等待!这是我的第一个问题,我也是 html 的初学者。
谢谢!!
【问题讨论】:
-
你能用你的代码做一个jsfiddle吗?
-
由于您所做的事情与我最近所做的事情非常接近,这里的 a bootply 显示了我用于自定义复选框的 html 和 css,利用 bootstrap 和 fontawesome。
标签: html css forms twitter-bootstrap checkbox