我已经适应从这个CodePen的.squaredThree
类的实例。如果你想看一个实例,我的答案底部有一个小提琴链接。
下面是更新后的CSS:
/* .squaredThree */
.squaredThree {
position: relative;
float:left;
}
.squaredThree label {
width: 20px;
height: 20px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
background: #D7B1D7;
border-radius: 4px;
box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.4);
}
.squaredThree label:after {
content: '';
width: 9px;
height: 5px;
position: absolute;
top: 4px;
left: 4px;
border: 3px solid #fcfff4;
border-top: none;
border-right: none;
background: transparent;
opacity: 0;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.squaredThree label:hover::after {
opacity: 0.3;
}
.squaredThree input[type=checkbox] {
visibility: hidden;
}
.squaredThree input[type=checkbox]:checked + label:after {
opacity: 1;
}
/* end .squaredThree */
我已经更新了你的HTML包含另一个label
,作为原始label
被用作伪复选框。这是你的更新HTML:
<div class="container">
<form name="queryForm" class="form-inline">
<div class="squaredThree">
<input type="checkbox" name="optionsRadios" id="checkOther" value="other" ng-model="formData.other" ng-true-value="'other'" ng-init="formData.other='other'">
<label for="checkOther"></label>
</div>
<label class="label-text">Other</label>
</form>
</div>
注意,附加label
存在.squaredThree
div
之外。该label
有一类.label-text
一些附加的样式规则的文字稍微移动到checkbox
权需要:
.label-text {
position: relative;
left: 10px;
}
最后,检查在checkbox
大小是不完全正确的,从而需要额外的规则来纠正:
*,
::before,
::after {
box-sizing: initial;
}
Fiddle Demo显示上述行动。
伴侣,这里回答这里http://stackoverflow.com/questions/28768623/how-do-you-change-the-style-of-a-bootstrap-checkbox和这里http://stackoverflow.com/问题/ 26821895 /更改颜色复选框标签时检查希望你得到它的工作。 – user3620318
链接到引导CSS的HTML代码不会重现您显示的结果。你使用一些插件还是有一些HTML(引导类缺失?因为一种方式是http://codepen.io/anon/pen/MeWemd –
我的答案有帮助吗?如果没有,请随时提出任何问题。 – Yass