Back-to-Top Button auf allen Seiten hinzugefügt mit Smooth-Scroll und Fade-in/out Effekt

This commit is contained in:
2026-02-11 19:09:09 +01:00
parent c535c7c448
commit a39403abd1
6 changed files with 76 additions and 9 deletions

View File

@@ -228,27 +228,49 @@ footer a:hover {
} }
} }
/* Scroll to Top Button (optional) */ /* Back to Top Button */
.scroll-to-top { .back-to-top {
position: fixed; position: fixed;
bottom: 2rem; bottom: 2rem;
right: 2rem; right: 2rem;
display: none; width: 3.5rem;
width: 3rem; height: 3.5rem;
height: 3rem;
background-color: var(--primary-color); background-color: var(--primary-color);
color: white; color: white;
border-radius: 50%; border-radius: 50%;
text-align: center; display: flex;
line-height: 3rem; align-items: center;
cursor: pointer; justify-content: center;
text-decoration: none;
font-size: 2rem;
z-index: 1000; z-index: 1000;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease; 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); background-color: var(--secondary-color);
color: white;
transform: translateY(-5px); 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) */ /* Loading Animation (optional) */

View File

@@ -259,6 +259,11 @@
</div> </div>
</footer> </footer>
<!-- Back to Top Button -->
<a href="#" id="back-to-top" class="back-to-top" aria-label="Nach oben scrollen">
<i class="bi bi-arrow-up-circle-fill"></i>
</a>
<!-- Bootstrap JS --> <!-- Bootstrap JS -->
<script src="js/bootstrap.bundle.min.js"></script> <script src="js/bootstrap.bundle.min.js"></script>
<!-- Custom JS --> <!-- Custom JS -->

View File

@@ -218,6 +218,11 @@
</div> </div>
</footer> </footer>
<!-- Back to Top Button -->
<a href="#" id="back-to-top" class="back-to-top" aria-label="Nach oben scrollen">
<i class="bi bi-arrow-up-circle-fill"></i>
</a>
<!-- Bootstrap JS --> <!-- Bootstrap JS -->
<script src="js/bootstrap.bundle.min.js"></script> <script src="js/bootstrap.bundle.min.js"></script>
<!-- Custom JS --> <!-- Custom JS -->

View File

@@ -257,6 +257,11 @@
</div> </div>
</footer> </footer>
<!-- Back to Top Button -->
<a href="#" id="back-to-top" class="back-to-top" aria-label="Nach oben scrollen">
<i class="bi bi-arrow-up-circle-fill"></i>
</a>
<!-- Bootstrap JS --> <!-- Bootstrap JS -->
<script src="js/bootstrap.bundle.min.js"></script> <script src="js/bootstrap.bundle.min.js"></script>
<!-- Custom JS --> <!-- Custom JS -->

View File

@@ -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'
});
});
}
});

View File

@@ -271,6 +271,11 @@
</div> </div>
</footer> </footer>
<!-- Back to Top Button -->
<a href="#" id="back-to-top" class="back-to-top" aria-label="Nach oben scrollen">
<i class="bi bi-arrow-up-circle-fill"></i>
</a>
<!-- Bootstrap JS --> <!-- Bootstrap JS -->
<script src="js/bootstrap.bundle.min.js"></script> <script src="js/bootstrap.bundle.min.js"></script>
<!-- Custom JS --> <!-- Custom JS -->