File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 < a href ="#hero "> < img src ="assets/logo.svg " alt ="Codebase " /> </ a >
2020 </ div >
2121 < ul class ="nav-links ">
22+ < li > < a href ="#hero "> Home</ a > </ li >
2223 < li > < a href ="#about "> About</ a > </ li >
2324 < li > < a href ="#services "> Services</ a > </ li >
2425 < li > < a href ="#reviews "> Reviews</ a > </ li >
@@ -424,6 +425,10 @@ <h2 class="section-title">Let's build something great together</h2>
424425 </ div >
425426</ footer >
426427
428+ < button id ="scrollTop " aria-label ="Scroll to top ">
429+ < svg xmlns ="http://www.w3.org/2000/svg " width ="18 " height ="18 " viewBox ="0 0 24 24 " fill ="none " stroke ="currentColor " stroke-width ="2.5 " stroke-linecap ="round " stroke-linejoin ="round "> < polyline points ="18 15 12 9 6 15 "/> </ svg >
430+ </ button >
431+
427432< script src ="script.js "> </ script >
428433</ body >
429434</ html >
Original file line number Diff line number Diff line change @@ -24,6 +24,15 @@ document.querySelectorAll('.nav-links a').forEach(link => {
2424 link . addEventListener ( 'click' , ( ) => navLinks . classList . remove ( 'open' ) ) ;
2525} ) ;
2626
27+ // ── SCROLL TO TOP ──
28+ const scrollTopBtn = document . getElementById ( 'scrollTop' ) ;
29+ window . addEventListener ( 'scroll' , ( ) => {
30+ scrollTopBtn . classList . toggle ( 'visible' , window . scrollY > 400 ) ;
31+ } ) ;
32+ scrollTopBtn . addEventListener ( 'click' , ( ) => {
33+ window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
34+ } ) ;
35+
2736// ── ACTIVE NAV HIGHLIGHT ──
2837const sections = document . querySelectorAll ( 'section[id]' ) ;
2938const navAnchors = document . querySelectorAll ( '.nav-links a[href^="#"]' ) ;
Original file line number Diff line number Diff line change @@ -743,6 +743,31 @@ body.dark #contact iframe {
743743body .dark footer { background : # 050505 ; }
744744body .dark .footer-logo img { filter : invert (0 ); opacity : 0.5 ; }
745745
746+ /* ── SCROLL TO TOP ── */
747+ # scrollTop {
748+ position : fixed;
749+ bottom : 2rem ;
750+ right : 2rem ;
751+ width : 44px ; height : 44px ;
752+ background : var (--black );
753+ color : var (--white );
754+ border : none;
755+ border-radius : 50% ;
756+ display : flex; align-items : center; justify-content : center;
757+ cursor : pointer;
758+ z-index : 99 ;
759+ opacity : 0 ;
760+ pointer-events : none;
761+ transform : translateY (10px );
762+ transition : opacity 0.3s ease, transform 0.3s ease, background 0.3s ease;
763+ box-shadow : 0 4px 16px rgba (0 , 0 , 0 , 0.2 );
764+ }
765+ # scrollTop .visible { opacity : 1 ; pointer-events : all; transform : translateY (0 ); }
766+ # scrollTop : hover { background : var (--gray-800 ); transform : translateY (-3px ); }
767+
768+ body .dark # scrollTop { background : # fff ; color : # 000 ; }
769+ body .dark # scrollTop : hover { background : # e8e8e8 ; }
770+
746771/* ── SCROLL ANIMATIONS ── */
747772.fade-up {
748773 opacity : 0 ;
You can’t perform that action at this time.
0 commit comments