88 </ div >
99</ body >
1010
11- </ html >
11+ </ html >
12+ < script >
13+ var date = new Date ( ) ;
14+ var month = date . getMonth ( ) + 1 ;
15+ if ( '12|1|2|' . indexOf ( month ) > - 1 ) {
16+ console . log ( '겨울이네요 눈이 내립니다! 헷' ) ;
17+ console . log ( '현재 url' , window . location . href ) ;
18+ doYouWannaBuildaSnowMan ( ) ;
19+ }
20+ // 눈내리는 효과를 주기위해...
21+ function doYouWannaBuildaSnowMan ( ) {
22+ const body = document . querySelector ( 'body' ) ;
23+ const MIN_DURATION = 10 ;
24+ var count = 0 ;
25+
26+ function makeSnowFlake ( ) {
27+ const snowflake = document . createElement ( "div" ) ;
28+ const delay = Math . random ( ) * 10 ;
29+ const initialOpacity = Math . random ( ) ;
30+ const duration = Math . random ( ) * 20 + MIN_DURATION ;
31+ snowflake . classList . add ( 'snowflake' ) ;
32+ snowflake . style . left = `${ Math . random ( ) * window . screen . width } px`
33+ snowflake . style . animationDelay = `${ delay } s` ;
34+ snowflake . style . opacity = initialOpacity ;
35+ snowflake . style . animation = `fall ${ duration } s linear` ;
36+ body . appendChild ( snowflake ) ;
37+ setTimeout ( ( ) => {
38+ body . removeChild ( snowflake ) ;
39+ if ( count <= 100 ) makeSnowFlake ( ) ;
40+ count ++ ;
41+ } , ( duration + delay ) * 1000 ) ;
42+ }
43+ for ( let index = 0 ; index < 50 ; index ++ ) {
44+ setTimeout ( makeSnowFlake ( ) , 500 * index ) ;
45+ }
46+ }
47+ </ script >
48+
49+
50+ < style >
51+ .snowflake {
52+ width : 8px ;
53+ height : 8px ;
54+ background-color : # 3482F6 ;
55+ border-radius : 50% ;
56+ position : absolute;
57+ top : -8px ;
58+ }
59+
60+ @keyframes fall {
61+ from {}
62+
63+ to {
64+ transform : translateY (100vh );
65+ opacity : 0 ;
66+ }
67+ }
68+ </ style >
0 commit comments