引入bootstrap checkBox css 及字体依赖 font-awesome
<link href="https://cdn.bootcss.com/awesome-bootstrap-checkbox/v0.2.3/awesome-bootstrap-checkbox.min.css" rel="stylesheet">
<link href="__TMPL__Public/assets/vendor/font-awesome/css/font-awesome.css" rel="stylesheet">
自定义样式
.checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {
position: relative;
margin-left: 10px;
}
.checkbox input[type="checkbox"]:focus + label::before,
.checkbox input[type="radio"]:focus + label::before {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
/* outline-offset: -2px;*/
background-color: #fff;
border-color:#46b8da;
}
.checkbox input[type="checkbox"]:checked + label::before,
.checkbox input[type="radio"]:checked + label::before {
background-color: #5bc0de;<!--选中后的背景颜色-->
border-color: #46b8da;<!--选中后的边框颜色-->
}
.checkbox input[type="checkbox"]:checked + label::after,
.checkbox input[type="radio"]:checked + label::after {
font-family: "FontAwesome";
content: "\f00c";
}
.checkbox input[type="checkbox"]:disabled + label,
.checkbox input[type="radio"]:disabled + label {
opacity: 0.65;
}
.checkbox input[type="checkbox"]:disabled + label::before,
.checkbox input[type="radio"]:disabled + label::before {
background-color: #eeeeee;
cursor: not-allowed;
}
.checkbox label::before {
font-size: 25px;
content: "";
display: inline-block;
position: absolute;
width: 30px; <!--大小-->
height: 30px; <!--大小-->
left: 0;
margin-left: -30px; <!--距离-->
border: 1px solid #ccc;
border-radius: 3px;
background-color: #fff;
-webkit-transition: border .15s ease-in-out,color .15s ease-in-out;
-o-transition: border .15s ease-in-out,color .15s ease-in-out;
transition: border .15s ease-in-out,color .15s ease-in-out;
}
.checkbox label::after {
display: inline-block;
position: absolute;
width: 30px;
height: 30px;
left: 0;
top: 0;
margin-left: -30px;
padding-left: 6px; <!--内部钩的距离-->
padding-top: -5px;<!--内部钩的距离-->
font-size: 20px;<!--内部钩的大小-->
color: #ad6969;
}
Html 应用
<!-- 在div 里设定 样式 checkbox checkbox-primary -->
<div class="checkbox checkbox-primary">
<input type="checkbox" id="keywordsType" checked="checked" class="styled" />
<label for="keywordsType" style=" font-size:18px;">
随机
</label>
</div>