diff --git a/assets/css/style.css b/assets/css/style.css index 380dfd7..b7d58b0 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2051,4 +2051,37 @@ textarea.input-field { left: 0; } -} \ No newline at end of file +} + + + +.back-top-btn { + z-index: 4; + opacity: 0; + visibility: hidden; + position: fixed; + bottom: 20px; + right: 20px; + background-color: #e8cb57; + color: #1a1a1a; + font-size: 24px; + width: 55px; + height: 55px; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); + transition: background-color 0.3s ease, opacity 0.3s ease; +} + +.back-top-btn:hover, .back-top-btn:focus-visible { + background-color: #ffffff; + color: #e4c33d; +} + +.back-top-btn.active { + opacity: 1; + visibility: visible; +} + diff --git a/assets/js/script.js b/assets/js/script.js index 290799a..8820508 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -143,4 +143,21 @@ window.addEventListener("mousemove", function (event) { parallaxItems[i].style.transform = `translate3d(${x}px, ${y}px, 0px)`; } -}); \ No newline at end of file +}); + + + +const backTopBtn = document.querySelector("[data-back-top-btn]"); + +const toggleButtonVisibility = () => { + const shouldShowButton = window.scrollY >= 50; + backTopBtn.classList.toggle("active", shouldShowButton); + + backTopBtn.style.zIndex = shouldShowButton ? '4' : ''; +}; + +window.addEventListener("scroll", toggleButtonVisibility); + +backTopBtn.addEventListener("click", () => { + window.scrollTo({ top: 0, behavior: "smooth" }); +}); diff --git a/index.html b/index.html index e97ba51..0065fd3 100644 --- a/index.html +++ b/index.html @@ -1064,8 +1064,9 @@