File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change 55
55
background-color : # 0056b3 ; /* Change this to your desired active background color */
56
56
border-radius : 4px ;
57
57
}
58
+ # back-to-top {
59
+ position : fixed;
60
+ bottom : 20px ;
61
+ right : 20px ;
62
+ display : none;
63
+ background-color : # 007bff ;
64
+ color : white;
65
+ border : none;
66
+ padding : 10px ;
67
+ border-radius : 50% ;
68
+ font-size : 18px ;
69
+ cursor : pointer;
70
+ }
71
+ # back-to-top : hover {
72
+ background-color : # 0056b3 ;
73
+ }
58
74
</ style >
59
75
</ head >
60
76
@@ -272,7 +288,7 @@ <h2 class="card-title">How to Create a GitHub Account</h2>
272
288
</ div >
273
289
</ div >
274
290
</ div >
275
-
291
+ < button id =" back-to-top " > < i class =" fa fa-chevron-up " > </ i > </ button >
276
292
<!-- Site footer -->
277
293
< footer class ="site-footer ">
278
294
< div class ="container ">
@@ -393,6 +409,23 @@ <h6>Quick Links</h6>
393
409
< script src ="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js "> </ script >
394
410
< script src ="./ScrollToTop.js "> </ script >
395
411
< script src ="//code.jquery.com/jquery-1.11.0.min.js "> </ script >
412
+ < script >
413
+ const backToTopButton = document . getElementById ( 'back-to-top' ) ;
414
+ window . addEventListener ( 'scroll' , ( ) => {
415
+ if ( window . scrollY > 300 ) {
416
+ backToTopButton . style . display = 'block' ;
417
+ } else {
418
+ backToTopButton . style . display = 'none' ;
419
+ }
420
+ } ) ;
421
+
422
+ backToTopButton . addEventListener ( 'click' , ( ) => {
423
+ window . scrollTo ( {
424
+ top : 0 ,
425
+ behavior : 'smooth'
426
+ } ) ;
427
+ } ) ;
428
+ </ script >
396
429
< script >
397
430
document . addEventListener ( 'DOMContentLoaded' , function ( ) {
398
431
fetch ( 'data.json' )
@@ -426,3 +459,5 @@ <h2 class="card-title">${post.title}</h2>
426
459
</ body >
427
460
428
461
</ html >
462
+
463
+
You can’t perform that action at this time.
0 commit comments