File tree Expand file tree Collapse file tree 3 files changed +126
-0
lines changed Expand file tree Collapse file tree 3 files changed +126
-0
lines changed Original file line number Diff line number Diff line change 1+ const grayHeart = document . querySelector ( ".gray-heart" ) ;
2+ const redHeart = document . querySelector ( ".red-heart" ) ;
3+
4+ grayHeart . addEventListener ( "click" , ( ) => {
5+ redHeart . classList . add ( "animation" ) ;
6+ grayHeart . classList . add ( "fill-color" ) ;
7+ } ) ;
8+
9+ redHeart . addEventListener ( "click" , ( ) => {
10+ redHeart . classList . remove ( "animation" ) ;
11+ grayHeart . classList . remove ( "fill-color" ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Heart</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < div class ="gray-heart "> </ div >
11+ < div class ="red-heart "> </ div >
12+
13+ < script src ="app.js "> </ script >
14+ </ body >
15+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ margin : 0 ;
4+ padding : 0 ;
5+ }
6+
7+ : root {
8+ --main-color : # dc143c ;
9+ }
10+
11+ body {
12+ display : flex;
13+ justify-content : center;
14+ align-items : center;
15+ height : 100vh ;
16+ background : rgb (7 , 7 , 20 );
17+ }
18+
19+ /* gray-heart */
20+ .gray-heart {
21+ background : # ccc ;
22+ display : flex;
23+ justify-content : center;
24+ align-items : center;
25+ width : 100px ;
26+ height : 100px ;
27+ position : relative;
28+ top : 0 ;
29+ transform : rotate (-45deg );
30+ }
31+
32+ .gray-heart : before ,
33+ .gray-heart : after {
34+ content : "" ;
35+ background : # ccc ;
36+ border-radius : 50% ;
37+ height : 100px ;
38+ width : 100px ;
39+ position : absolute;
40+ }
41+
42+ .gray-heart : before {
43+ top : -50px ;
44+ left : 0 ;
45+ }
46+
47+ .gray-heart : after {
48+ left : 50px ;
49+ top : 0 ;
50+ }
51+
52+ /* red-heart */
53+ .red-heart {
54+ background : var (--main-color );
55+ display : flex;
56+ justify-content : center;
57+ align-items : center;
58+ height : 100px ;
59+ width : 100px ;
60+ transform : rotate (-45deg );
61+ position : absolute;
62+ visibility : hidden;
63+ }
64+
65+ .red-heart : before ,
66+ .red-heart : after {
67+ content : "" ;
68+ background : var (--main-color );
69+ border-radius : 50% ;
70+ width : 100px ;
71+ height : 100px ;
72+ position : absolute;
73+ }
74+
75+ .red-heart : before {
76+ top : -50px ;
77+ left : 0 ;
78+ }
79+
80+ .red-heart : after {
81+ left : 50px ;
82+ top : 0 ;
83+ }
84+
85+ .red-heart .animation {
86+ animation : pop 0.9s linear;
87+ visibility : visible;
88+ }
89+
90+ .red-heart .fill-color {
91+ background : var (--main-color );
92+ }
93+
94+ @keyframes pop {
95+ 100% {
96+ transform : scale (1.7 ) rotate (-45deg );
97+ opacity : 0 ;
98+ }
99+ }
You can’t perform that action at this time.
0 commit comments