自定义复选框不起作用

GVF*_*GVF 2 html css forms checkbox twitter-bootstrap

我正在使用bootstrap 3和另一个css模板.我想使用模板对复选框进行样式化,但它不起作用,因为我无法使用输入区域.当我点击它时,什么都没有出现. 这是代码:

HTML:

<div class="checkbox check-primary ">
<input type="checkbox" value=""> 
<label>Guardar usuario</label>
</div>
Run Code Online (Sandbox Code Playgroud)

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;
}
Run Code Online (Sandbox Code Playgroud)

那一切.该复选框仅在我出现此规则时运行:.checkbox input [type = checkbox] {display:none; }

如果我有很多错误,请耐心等待!这是我的第一个问题,我也是html的初级问题.

谢谢!!

cov*_*efe 7

如果标签不在标签中,则单击标签不会更改输入状态<label>.您必须添加id复选框和for=""带有复选框ID的属性到标签才能使其工作:

<div class="checkbox check-primary ">
    <input id="checkbox-1" type="checkbox" value="">
    <label for="checkbox-1">Guardar usuario</label>
</div>
Run Code Online (Sandbox Code Playgroud)