File tree Expand file tree Collapse file tree 3 files changed +127
-0
lines changed Expand file tree Collapse file tree 3 files changed +127
-0
lines changed Original file line number Diff line number Diff line change 1+ let arrow = document . getElementById ( "arrow" ) ;
2+
3+ window . addEventListener ( "scroll" , ( ) => {
4+ let position = window . scrollY ;
5+ // console.log(position);
6+ if ( position <= 5 ) {
7+ arrow . classList . toggle ( "fade-in" ) ;
8+ arrow . classList . toggle ( "fade-out" ) ;
9+ }
10+ } ) ;
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 > Fade Out</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < h1 > Arrow fade out no scroll</ h1 >
12+ < p class ="sub-headings ">
13+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem
14+ voluptatem doloribus ea itaque ipsum soluta aut dolor, perspiciatis
15+ mollitia recusandae omnis qui a corporis impedit. Qui commodi
16+ accusantium exercitationem ullam?
17+ </ p >
18+ < div class ="arrow " id ="arrow "> </ div >
19+ </ div >
20+
21+ < script src ="app.js "> </ script >
22+ </ body >
23+ </ 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+ html ,
8+ body {
9+ width : 100% ;
10+ height : 200vh ;
11+ background : # 000 ;
12+ }
13+
14+ .container {
15+ display : flex;
16+ flex-direction : column;
17+ justify-content : center;
18+ align-items : center;
19+ color : # fff ;
20+ }
21+
22+ .sub-headings {
23+ max-width : 700px ;
24+ text-align : center;
25+ margin : 20px ;
26+ font-family : sans-serif;
27+ line-height : 30px ;
28+ }
29+
30+ h1 {
31+ margin-top : 50px ;
32+ color : # fff ;
33+ text-align : center;
34+ font-size : 4rem ;
35+ margin-bottom : 6rem ;
36+ }
37+
38+ .arrow {
39+ width : 45px ;
40+ height : 45px ;
41+ border : 2px solid white;
42+ border-radius : 50% ;
43+ position : absolute;
44+ bottom : 30px ;
45+ margin : auto;
46+ transition : ease-in;
47+ animation : bounce 1.5s infinite;
48+ }
49+
50+ .arrow : before {
51+ content : "" ;
52+ position : absolute;
53+ top : 11px ;
54+ left : 13px ;
55+ width : 12px ;
56+ height : 12px ;
57+ border-left : 2px solid # fafafa ;
58+ border-bottom : 2px solid # fafafa ;
59+ transform : rotate (-45deg );
60+ }
61+
62+ @keyframes bounce {
63+ 0% {
64+ transform : translate (0 );
65+ }
66+ 20% {
67+ transform : translateY (15px );
68+ }
69+ 40% {
70+ transform : translate (0 );
71+ }
72+ }
73+
74+ @-webkit-keyframes bounce {
75+ 0% {
76+ transform : translate (0 );
77+ }
78+ 20% {
79+ transform : translateY (15px );
80+ }
81+ 40% {
82+ transform : translate (0 );
83+ }
84+ }
85+
86+ .fade-in {
87+ opacity : 1 ;
88+ transition : 1s all ease-in;
89+ }
90+
91+ .fade-out {
92+ opacity : 0 ;
93+ transition : 1s all ease-out;
94+ }
You can’t perform that action at this time.
0 commit comments