选择2 选择3 选择4 选择5
<form action="">
  <label for="test">选择1
            <input type="checkbox" id="test">
            <div class="checkboxdiv"></div>
        </label> 选择2
  <input type="checkbox"> 选择3
  <input type="checkbox"> 选择4
  <input type="checkbox"> 选择5
  <input type="checkbox">
</form>

 

label {
  font-size: 12px;
/*   调整vertical-align的值实现水平对齐 */
  vertical-align: 3px;
}
/* 将默认的样式隐藏,使用另一个div模拟 */
#test {
  display: none;
}

.checkboxdiv {
  width: 30px;
  height: 30px;
  display: inline-block;
    border-radius: 3px;
        border:1px solid #85a2cd;
        margin-right: 10px;
        vertical-align: middle;
}

#test:checked ~.checkboxdiv {
  background-color: red;
}

 https://codepen.io/anon/pen/VrmjvG

相关文章:

  • 2021-07-01
  • 2022-12-23
  • 2021-09-09
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案