|
Sunday, July 7th, 2024
Plus icons
ラベル要素とインプット要素を使用してアイコンを実装します。
ご自由にご利用ください。
Previews
Examples html
<!-- icons -->
<div class="icons">
<input type="checkbox" name="checkbox" id="checkbox" />
<label for="checkbox" class="label">
<span class="item"></span>
</label>
</div>
<!-- /icons -->
Examples css
/* - icons - */
.icons {
position: relative;
width: 25px;
height: 25px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
background-color: rgba(0, 0, 0, 0.0);
}
input[type="checkbox"] {
display: none;
}
label.label {
display: block;
position: absolute;
top: 0px;
left: 0px;
width: 25px;
height: 25px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
background-color: rgba(0, 0, 0, 0.0);
cursor: pointer;
transition: all .5s;
}
label.label span.item::before,
label.label span.item::after {
content: "";
display: block;
position: absolute;
top: 11.5px;
left: 0px;
width: 100%;
height: 2px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
background-color: rgba(0, 0, 0, 1.0);
border-radius: 1px 1px 1px 1px;
transition: all .5s;
}
label.label span.item::after {
transform: rotate(90deg);
}
label.label:hover span.item::before,
label.label:hover span.item::after {
background-color: rgba(192, 192, 192, 1.0);
}
label.label:active span.item::before,
label.label:active span.item::after {
background-color: rgba(0, 0, 0, 1.0);
}
input[type="checkbox"]:checked ~ label.label {
transform: rotate(45deg);
}
/* - /icons - */
Summary
最後までご高覧いただきましてありがとうございました。
ラベル要素とインプット要素を使用して実装するアイコンをご紹介させていただきました。
必要に応じて各コードを変更してご自由にご利用ください。
現場からは以上でした。