Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,31 @@ footer .contact_link:hover,
width: 50%;
}
}

.to-top {
background: greenyellow;
position: fixed;
bottom: 16px;
right:32px;
width:50px;
height:50px;
border-radius:50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
color: #1f1f1f;
text-decoration: none;
opacity:0;
pointer-events: none;
transition: all .4s;
}
.to-top.active {
bottom: 32px;
pointer-events: auto;
opacity:1;
}
html {
scroll-behavior: smooth;
}

5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Arito - Practice Math Skills</title>
<link rel="stylesheet" href="css/basic.css">
<link rel="shortcut icon" href="assets/images/Arito_favicon.png">

<script src="https://kit.fontawesome.com/59c338ca6e.js" crossorigin="anonymous"></script>
<link rel="manifest" href="./manifest.json">
</head>
<link rel="stylesheet" href="css/index.css">
Expand Down Expand Up @@ -46,6 +46,9 @@ <h2>🤔 Reviews & Reactions 😍</h2>

</div>
</footer>
<a href="#" class="to-top">
<i class="fas fa-chevron-up"></i>
</a>

</body>
<script src="js/index.js"></script>
Expand Down
10 changes: 10 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Scroll to the top when the button is clicked
const toTop = document.querySelector(".to-top");

window.addEventListener("scroll", () => {
if(window.pageYOffset >100) {
toTop.classList.add("active");
} else {
toTop.classList.remove("active");
}
})