پیشنمایش زنده
کد HTML
<button class="theme__icon">
<span></span>
<span>
<span></span>
<span></span>
<span></span>
<span></span>
</span>
<span></span>
</button>
کد CSS
/* <reset-style> ============================ */
button {
border: none;
background: none;
padding: 0;
margin: 0;
cursor: pointer;
font-family: inherit;
}
/* <main-style> ============================ */
.theme__icon {
width: 32px;
height: 32px;
padding: 4px;
overflow: hidden;
position: relative;
}
.theme__icon > :nth-child(1) {
width: 14px;
height: 14px;
border-radius: 24px;
border: 1px solid #212121;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgb(255, 204, 0);
transition: width .4s, height .4s, border .4s, background-color .4s;
z-index: 10;
}
.theme__icon:hover > :nth-child(1) {
width: 24px;
height: 24px;
border: 1px solid rgb(245, 245, 247);
background-color: rgb(245, 245, 247);
}
.theme__icon > :nth-child(2) {
width: 24px;
height: 24px;
border-radius: 24px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: transform .4s;
}
.theme__icon:hover > :nth-child(2) {
transform: translate(-50%, -50%) rotate(-45deg) scale(.8);
}
.theme__icon > :nth-child(2) > :nth-child(1) {
display: block;
width: 2px;
height: 24px;
border-radius: 2px;
position: relative;
top: 0;
left: 50%;
transform: translateX(-50%);
background-color: rgb(255, 204, 0);
}
.theme__icon > :nth-child(2) > :nth-child(2) {
display: block;
width: 24px;
height: 2px;
border-radius: 2px;
position: relative;
top: -54%;
left: 50%;
transform: translateX(-50%);
background-color: rgb(255, 204, 0);
}
.theme__icon > :nth-child(2) > :nth-child(3) {
display: block;
width: 24px;
height: 2px;
border-radius: 2px;
position: relative;
top: -60%;
left: 50%;
transform: translateX(-50%) rotate(45deg);
background-color: rgb(255, 204, 0);
}
.theme__icon > :nth-child(2) > :nth-child(4) {
display: block;
width: 24px;
height: 2px;
border-radius: 2px;
position: relative;
top: -70%;
left: 50%;
transform: translateX(-50%) rotate(-45deg);
background-color: rgb(255, 204, 0);
}
.theme__icon > :nth-child(3) {
width: 20px;
height: 20px;
border-radius: 24px;
position: absolute;
top: 50%;
left: 100%;
transform: translateY(-50%);
background-color: #212121;
transition: top .4s, left .4s;
transition-delay: .2s;
z-index: 20;
}
.theme__icon:hover > :nth-child(3) {
top: 35%;
left: 40%;
}