<div class="cp_ipcheck01">
<input type="checkbox" id="a_ch1" checked /><label for="a_ch1">ネコ</label>
<input type="checkbox" id="a_ch2" /><label for="a_ch2">イヌ</label>
<input type="checkbox" id="a_ch3" /><label for="a_ch3">ウサギ</label>
<input type="checkbox" id="a_ch4" disabled /><label for="a_ch3">ウサギ</label>
</div>
.cp_ipcheck01 {
margin: 6em 2em;
}
.cp_ipcheck01 input[type=checkbox] {
display: none;
}
/*通常時のラベルの設定*/
.cp_ipcheck01 label {
position: relative;
display: flex;
align-items: center;
padding: 0 0 0 20px;
text-overflow: ellipsis;/*テキストがエリアを超えたら'…'で省略*/
transition: all 0.15s ease;
cursor: pointer;
}
/*通常時のチェックボックスの設定*/
.cp_ipcheck01 label::before {
position: absolute;
left: 0px;
content: '';
width: 10px;
height: 10px;
border: 0.2em solid #cccccc;
}
/* focus・hover・active・checked時のテキストの設定*/
.cp_ipcheck01 label:focus,
.cp_ipcheck01 label:hover,
.cp_ipcheck01 label:active,
.cp_ipcheck01 input:checked + label {
color: #da3c41;
}
/* focus・hover・active時のチェックボックスの設定*/
.cp_ipcheck01 label:focus::before,
.cp_ipcheck01 label:hover::before,
.cp_ipcheck01 label:active::before {
border-color: #da3c41;
background: #ffffff;
}
/* checked時のチェックボックスの設定*/
.cp_ipcheck01 input:checked + label::before {
border-color: #da3c41;
background: #da3c41;
}
/*disabled時の設定*/
.cp_ipcheck01 input:disabled + label {
cursor: not-allowed;
color: #b8b7b7;
}
.cp_ipcheck01 input:disabled + label::before {
border-color: #b8b7b7;
background: #b8b7b7;
}
.cp_ipcheck01 input:disabled + label::after {
position: absolute;
left: 2px;
content: '✖︎';
color: #666666;
}