Skip to content

Commit 4399f2a

Browse files
committedFeb 10, 2022
feat: floating action button
1 parent 8a8db19 commit 4399f2a

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
 

‎app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const scrollBtn = document.querySelector(".floating");
2+
3+
scrollBtn.addEventListener("click", () => window.scrollTo(0,0));

‎css/docs.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ aside {
119119
display: block;
120120
}
121121

122+
/* FLOATING ACTION BUTTON */
123+
.floating {
124+
position: fixed;
125+
right: 1rem;
126+
bottom: 1rem;
127+
}
128+
122129
/* MAIN CONTENT */
123130
main {
124131
margin-left: var(--side-nav-width);

‎docs.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ <h2 class="side-nav-heading">Components</h2>
4747
</aside>
4848

4949
<main>
50+
<button class="btn btn-dark floating">Scroll to top ⬆️</button>
5051
<!-- Getting Started -->
5152
<section id="getting-started">
5253
<header class="section-header">Getting Started</header>
@@ -663,6 +664,7 @@ <h2>Center Text</h2>
663664
<!-- highlight js -->
664665
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/highlight.min.js"></script>
665666
<script>hljs.highlightAll();</script>
667+
<script src="./app.js"></script>
666668
</main>
667669

668670

0 commit comments

Comments
 (0)