【发布时间】:2019-02-13 20:41:13
【问题描述】:
我知道这个问题之前已经回答过,但没有一个答案对我有用,所以无论我做错了什么,我都需要帮助。我希望我的复选框在单击后具有绿色背景色和白色复选标记。我在下面添加了我的代码,在 codepen 链接中您可以查看更多详细信息。
Codepen 链接:--> https://codepen.io/paulamourad/pen/oPpbEm
/* Customize the label (the container) */
.form-check {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 0.9em;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Hide the browser's default checkbox */
.form-check input {
position: absolute;
opacity: 0;
cursor: pointer;
}
/* Create a custom checkbox */
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 20px;
width: 20px;
border: 2px solid #D6D4D4;
}
/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
content: "";
position: absolute;
display: none;
}
/* Show the checkmark when checked */
.form-check input:checked~.checkmark:after {
display: block;
}
/* Style the checkmark/indicator */
.form-check .checkmark:after {
left: 2px;
top: 3px;
width: 5px;
height: 10px;
border: solid #8ABE57;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
<label class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checkPeriodDays">
<span class="checkmark"></span>
<label class="form-check-label ml-2" for="checkPeriodDays">
Días
</label>
</label>
【问题讨论】:
标签: html css bootstrap-4