Skip to content

Commit

Permalink
arrowBtn
Browse files Browse the repository at this point in the history
  • Loading branch information
atongjonathan committed Nov 25, 2023
1 parent a2a115c commit f8321a6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<title>Jonathan Atong</title>
</head>
<body>
<section class="header">
<section class="header" id="top">
<div class="name-div">
<a class="name" href="">
<span><</span>
Expand Down Expand Up @@ -136,13 +136,19 @@ <h3 class="section-title">Data Analysis</h3>
<p>⚡ Creating application backend in Node, Express & Flask</p>
</div>
</div>
<a title="Go top" href="#top">
<div class="arrow" id="arrow">
<i class="fa fa-arrow-up" aria-hidden="true"></i>
</div>
</a>



</div>

</section>
</main>

<script src="./script.js"></script>



Expand Down
13 changes: 13 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
document.addEventListener("DOMContentLoaded", ()=>{
window.onscroll = ()=>{
let distanceScrolled = window.scrollY;
let arrowBtn = document.getElementById("arrow")
if (distanceScrolled>0)
{
arrowBtn.style.visibility = "visible";
}
else{
arrowBtn.style.visibility = "hidden";
}
};
});
15 changes: 15 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,18 @@ a{
padding: 10px;
margin-top: 10px;
}
.arrow
{
position: fixed;
bottom: 20px;
right: 20px;
padding: 15px;
background-color: rgb(0, 28, 85);
color: rgb(237, 249, 254);
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
border-radius: 47%;
visibility: hidden;
}

0 comments on commit f8321a6

Please sign in to comment.