.css
.scroll-to-top {
position: fixed;
right: 1rem;
bottom: 1rem;
display: none;
width: 2.75rem;
height: 2.75rem;
text-align: center;
color: #fff;
background: rgba(90, 92, 105, 0.5);
line-height: 46px;
}
.scroll-to-top:focus, .scroll-to-top:hover {
color: white;
}
.scroll-to-top:hover {
background: #5a5c69;
}
.scroll-to-top i {
font-weight: 800;
}
.js
(function ($) {
"use strict"; // Start of use strict
// Scroll to top button appear
$(document).on("scroll", function () {
var scrollDistance = $(this).scrollTop();
if (scrollDistance > 100) {
$(".scroll-to-top").fadeIn();
} else {
$(".scroll-to-top").fadeOut();
}
});
// Smooth scrolling using jQuery easing
$(document).on("click", "a.scroll-to-top", function (e) {
var $anchor = $(this);
$("html, body").stop().animate({
scrollTop: ($($anchor.attr("href")).offset().top)
}, 200, "easeInOutExpo");
e.preventDefault();
});
})(jQuery);
.html
...
<body id="page-top">
<div class="wrapper">
...
</div>
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
...
</body>
</html>
'spring' 카테고리의 다른 글
spring boot custom auto configuration (0) | 2024.10.12 |
---|---|
spring boot fast log4j2 (0) | 2024.10.12 |
spring boot 가상 스레드 (0) | 2024.10.12 |
spring boot 가상 스레드로 Async 및 Scheduled 어노테이션 사용 (0) | 2024.10.12 |
spring boot 가상 스레드로 Redis 사용 (0) | 2024.10.12 |