Skip to content

Commit cf5654b

Browse files
committed
animation
1 parent f48e931 commit cf5654b

File tree

1 file changed

+62
-18
lines changed

1 file changed

+62
-18
lines changed

style.css

+62-18
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,46 @@
6666
font-size: 100%;
6767
position: absolute;
6868
top: 2%;
69-
left: 2%;
7069
width: 100px;
7170
height: 100px;
7271
background-color: white;
7372
border-radius: 50%;
74-
z-index: 9999;
75-
}
76-
77-
.sidebar-toggle-button {
78-
position: fixed;
79-
top: 2%;
8073
left: 88%;
81-
cursor: pointer;
8274
z-index: 9999;
83-
user-select: none;
84-
transition: 200ms ease all;
8575
font-size: 72px;
8676
}
8777

88-
#sidebar-toggle:checked + .sidebar-toggle-button::before {
89-
content: "✕";
90-
}
78+
#sidebar-toggle:checked ~ .sidebar-toggle-button::before {
79+
animation-name: to-x;
80+
animation-duration: 500ms;
81+
animation-fill-mode: forwards;
82+
}
83+
84+
#sidebar-toggle:not(checked) ~ .sidebar-toggle-button::before {
85+
animation-name: to-ham;
86+
animation-duration: 500ms;
87+
animation-fill-mode: forwards;
88+
}
89+
90+
@keyframes to-ham {
91+
from {
92+
content: "✕";
93+
}
94+
to {
95+
transform:rotateZ(1turn);
96+
content: "☰";
97+
}
98+
}
99+
100+
@keyframes to-x {
101+
from {
102+
content: "☰";
103+
}
104+
to {
105+
transform:rotateZ(-1turn);
106+
content: "✕";
107+
}
108+
}
91109

92110
#sidebar-toggle:checked ~ .sidebar {
93111
right: 0px;
@@ -109,7 +127,6 @@
109127
height: 100px;
110128
background-color: white;
111129
border-radius: 50%;
112-
transition: transform 200ms;
113130
z-index: 9999;
114131
}
115132

@@ -121,9 +138,37 @@
121138
background-color: #323232;
122139
}
123140

124-
#theme-toggle:checked + .theme-toggle-button::before {
125-
content: "🌑";
126-
}
141+
@keyframes to-moon {
142+
from {
143+
content: "☀️";
144+
}
145+
to {
146+
transform:rotateZ(1turn);
147+
content: "🌑";
148+
}
149+
}
150+
151+
@keyframes to-sun {
152+
from {
153+
content: "🌑";
154+
}
155+
to {
156+
transform:rotateZ(-1turn);
157+
content: "☀️";
158+
}
159+
}
160+
161+
#theme-toggle:checked ~ .theme-toggle-button::before {
162+
animation-name: to-moon;
163+
animation-duration: 500ms;
164+
animation-fill-mode: forwards;
165+
}
166+
167+
#theme-toggle:not(checked) ~ .theme-toggle-button::before {
168+
animation-name: to-sun;
169+
animation-duration: 500ms;
170+
animation-fill-mode: forwards;
171+
}
127172

128173
#theme-toggle:checked ~ .main {
129174
background: #051428;
@@ -153,7 +198,6 @@
153198
height: 50px;
154199
background-color: white;
155200
border-radius: 50%;
156-
transition: transform 200ms;
157201
z-index: 9999;
158202
}
159203

0 commit comments

Comments
 (0)