我已經適應從這個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