我有以下html代码:
<div class="container">
<form name="queryForm" class="form-inline text-center">
<p class="checkbox-inline">
<input type="checkbox" name="optionsRadios" id="checkOther" value="other" ng-model="formData.other" ng-true-value="'other'" ng-init="formData.other='other'">Other</p>
</form>
</div>
结果是:
将颜色更改为给定颜色(例如D7B1D7)的最简单方法是什么?
我已.squaredThree
将此CodePen中的类改编为您的示例。如果您想看现场示例,我的答案底部有一个Fiddle链接。
这是更新的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,使其包含另一个HTML label
,因为原始HTMLlabel
被用作伪复选框。这是您更新的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;
}
小提琴演示,上面显示了上述操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句