Issue
I have the following HTML code:
<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>
and the result of that is:
What's the simplest way of changing this color to a given one, for example D7B1D7?
Solution
I've adapted the .squaredThree
class from this CodePen for your example. There's a Fiddle link at the bottom of my answer if you want to see a live example.
Here's the updated 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 */
I've updated your HTML to include another label
, as the original label
is used as a pseudo checkbox. This is your updated 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>
Note that the additional label
exists outside the .squaredThree
div
. The label
has a class of .label-text
as some additional styling rules are needed to move the text slightly to the right of the checkbox
:
.label-text {
position: relative;
left: 10px;
}
Finally, the size of the check in the checkbox
isn't quite right so an additional rule is needed to rectify that:
*,
::before,
::after {
box-sizing: initial;
}
Fiddle Demo showing the above in action.
Answered By - Yass
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.