From a39403abd139ace59a68cf7daa50b1cc94709c5d Mon Sep 17 00:00:00 2001 From: webfarben Date: Wed, 11 Feb 2026 19:09:09 +0100 Subject: [PATCH] =?UTF-8?q?Back-to-Top=20Button=20auf=20allen=20Seiten=20h?= =?UTF-8?q?inzugef=C3=BCgt=20mit=20Smooth-Scroll=20und=20Fade-in/out=20Eff?= =?UTF-8?q?ekt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/style.css | 40 +++++++++++++++++++++++++++++++--------- datenschutz.html | 5 +++++ impressum.html | 5 +++++ index.html | 5 +++++ js/main.js | 25 +++++++++++++++++++++++++ kontakt.html | 5 +++++ 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/css/style.css b/css/style.css index 6e84d0e..b7c4dd9 100644 --- a/css/style.css +++ b/css/style.css @@ -228,27 +228,49 @@ footer a:hover { } } -/* Scroll to Top Button (optional) */ -.scroll-to-top { +/* Back to Top Button */ +.back-to-top { position: fixed; bottom: 2rem; right: 2rem; - display: none; - width: 3rem; - height: 3rem; + width: 3.5rem; + height: 3.5rem; background-color: var(--primary-color); color: white; border-radius: 50%; - text-align: center; - line-height: 3rem; - cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + text-decoration: none; + font-size: 2rem; z-index: 1000; + opacity: 0; + visibility: hidden; transition: all 0.3s ease; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); } -.scroll-to-top:hover { +.back-to-top.show { + opacity: 1; + visibility: visible; +} + +.back-to-top:hover { background-color: var(--secondary-color); + color: white; transform: translateY(-5px); + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); +} + +/* Mobile: kleinerer Button */ +@media (max-width: 768px) { + .back-to-top { + bottom: 1rem; + right: 1rem; + width: 3rem; + height: 3rem; + font-size: 1.5rem; + } } /* Loading Animation (optional) */ diff --git a/datenschutz.html b/datenschutz.html index abddc27..94c499e 100644 --- a/datenschutz.html +++ b/datenschutz.html @@ -259,6 +259,11 @@ + + + + + diff --git a/impressum.html b/impressum.html index 1e3df85..89c3f5c 100644 --- a/impressum.html +++ b/impressum.html @@ -218,6 +218,11 @@ + + + + + diff --git a/index.html b/index.html index c76125a..3d2e537 100644 --- a/index.html +++ b/index.html @@ -257,6 +257,11 @@ + + + + + diff --git a/js/main.js b/js/main.js index fe7efb3..ab8d14b 100644 --- a/js/main.js +++ b/js/main.js @@ -194,3 +194,28 @@ document.querySelectorAll('a[href^="#"]').forEach(anchor => { } }); }); + +// Back to Top Button +document.addEventListener('DOMContentLoaded', () => { + const backToTopButton = document.getElementById('back-to-top'); + + if (backToTopButton) { + // Button bei Scroll anzeigen/verstecken + window.addEventListener('scroll', () => { + if (window.pageYOffset > 300) { + backToTopButton.classList.add('show'); + } else { + backToTopButton.classList.remove('show'); + } + }); + + // Button Klick-Event + backToTopButton.addEventListener('click', (e) => { + e.preventDefault(); + window.scrollTo({ + top: 0, + behavior: 'smooth' + }); + }); + } +}); diff --git a/kontakt.html b/kontakt.html index 19d47af..878dd01 100644 --- a/kontakt.html +++ b/kontakt.html @@ -271,6 +271,11 @@ + + + + +