如何更改引导复选框的样式 [英] How do you change the style of a bootstrap checkbox
本文介绍了如何更改引导复选框的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一直在寻找如何改变引导复选框的风格,并已检查其他尝试!在这里,然而每一个尝试都没有成功,所以有一个方法来成功地改变引导复选框的样式或一个普通的复选框。
ive been looking on how to change the style of a bootstrap checkbox, and HAVE CHECKED THE OTHER ATTEMPTS! Made on here however every single attempt has not been successful, so is there a way to successfully change the style of a bootstrap check box or a normal checkbox.
<label>text</label>
<input type="checkbox"/>
UPDATED
http://jsfiddle.net/s12jx7su/1/
推荐答案
这里是我使用的自定义复选框的 演示bootply ,为图标实现引导图元。
Here's a demo bootply for custom checkboxes that I use, implementing bootstraps glyphicons for the icons. These degrade to ordinary checkboxes in IE8 without any additional code.
这里是相关的CSS:
.custom-checkbox > [type="checkbox"],
.custom-checkbox > label{
margin-bottom:0px !important;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.custom-checkbox > [type="checkbox"]:not(:checked),
.custom-checkbox > [type="checkbox"]:checked {
position: absolute;
left: -9999px;
}
.custom-checkbox > [type="checkbox"]:not(:checked) + label,
.custom-checkbox > [type="checkbox"]:checked + label {
position: relative;
padding-left: 22px;
cursor: pointer;
}
.custom-checkbox > [type="checkbox"]:not(:checked) + label:before,
.custom-checkbox > [type="checkbox"]:checked + label:before {
content: '';
position: absolute;
left:0;
top: 50%;
margin-top:-9px;
width: 17px;
height: 17px;
border: 1px solid #ddd;
background: #ffffff;
border-radius: 2px;
}
.custom-checkbox > [type="checkbox"]:not(:checked) + label:after,
.custom-checkbox > [type="checkbox"]:checked + label:after {
font: normal normal normal 12px/1 'Glyphicons Halflings';
content: '\e013';
position: absolute;
top: 50%;
margin-top:-7px;
left: 2px;
color: #94C947;
xtransition: all .2s;
}
.custom-checkbox > [type="checkbox"]:not(:checked) + label:after {
opacity: 0;
transform: scale(0);
}
.custom-checkbox > [type="checkbox"]:checked + label:after {
opacity: 1;
transform: scale(1);
}
.custom-checkbox > [type="checkbox"][data-indeterminate] + label:after,
.custom-checkbox > [type="checkbox"][data-indeterminate] + label:after {
content: '\2212';
left: 2px;
opacity: 1;
transform: scale(1);
}
.custom-checkbox > [type="checkbox"]:disabled:not(:checked) + label:before,
.custom-checkbox > [type="checkbox"]:disabled:checked + label:before {
box-shadow: none;
background-color: #eeeeee;
border-color: #eeeeee;
cursor: not-allowed;
opacity: 1;
color: #dadada;
}
.custom-checkbox > [type="checkbox"]:disabled:checked + label:after {
color: #dadada; cursor: not-allowed;
}
.custom-checkbox > [type="checkbox"]:disabled + label {
color: #aaa; cursor: not-allowed;
}
.custom-checkbox > [type="checkbox"]:checked:focus + label:before,
.custom-checkbox > [type="checkbox"]:not(:checked):focus + label:before {
border: 1px solid #66afe9;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
.custom-checkbox > label:hover:before {
border: 1px solid #88D2FF !important;
}
.custom-checkbox > [type="checkbox"]:disabled:not(:checked) + label:hover:before,
.custom-checkbox > [type="checkbox"]:disabled:checked + label:hover:before{
border: 1px solid #E4E4E4 !important;
}
和HTML:
<div class="custom-checkbox">
<input type="checkbox" id="cb1">
<label for="cb1">Fancy Checkbox</label>
</div>
HTH,-Ted
这篇关于如何更改引导复选框的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文