Skip to content

Commit 7a92d42

Browse files
committed
Improve scroll-to-top button styling and behavior
1 parent 34e95e6 commit 7a92d42

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

_includes/footer.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{% assign t = site.data.locales[page.lang][page.lang] %}
2-
<button id="scrollToTopButton" title="Go to top">Scroll to Top</button>
2+
<button id="scrollToTopButton" title="Go to top" aria-label="Scroll to top">
3+
<svg aria-hidden="true" viewBox="0 0 24 24" focusable="false">
4+
<path d="M12 4L5 11h4v9h6v-9h4z"></path>
5+
</svg>
6+
</button>
37
<footer class="bg-white border-top text-center pt-5">
48
<div class="container-lg p-responsive mx-auto">
59

assets/css/button.scss

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
bottom: 20px;
55
right: 20px;
66
z-index: 99;
7-
font-size: 16px;
8-
background-color: #333;
9-
color: #fff;
10-
border: none;
7+
width: 44px;
8+
height: 44px;
9+
padding: 0;
10+
align-items: center;
11+
justify-content: center;
12+
background-color: #fff;
13+
color: #6a737d;
14+
border: 1px solid #d0d7de;
1115
cursor: pointer;
12-
padding: 10px;
13-
border-radius: 4px;
14-
}
16+
border-radius: 50%;
17+
box-shadow: 0 2px 6px rgba(27, 31, 35, 0.12);
18+
}
19+
20+
#scrollToTopButton:hover {
21+
background-color: #f6f8fa;
22+
border-color: #afb8c1;
23+
}
24+
25+
#scrollToTopButton svg {
26+
width: 20px;
27+
height: 26px;
28+
display: block;
29+
fill: #6a737d;
30+
}

assets/js/button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
window.addEventListener('scroll', function () {
33
var scrollToTopButton = document.getElementById('scrollToTopButton');
44
if (window.scrollY > 300) {
5-
scrollToTopButton.style.display = 'block';
5+
scrollToTopButton.style.display = 'flex';
66
} else {
77
scrollToTopButton.style.display = 'none';
88
}

0 commit comments

Comments
 (0)