Skip to content

Commit

Permalink
Merge pull request #82 from Aaryanb45/main
Browse files Browse the repository at this point in the history
Addition of Scroll-to-Top Button #79
  • Loading branch information
MastanSayyad authored Jul 6, 2024
2 parents 95d04f3 + ae0087b commit 555355a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
23 changes: 22 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1858,4 +1858,25 @@ body {
h2 {
font-size: 1.5rem;
}
}
}



.topbtn{
position: fixed;
width: 50px;
height: 50px;
background: #7971ea;
bottom: 11px;
right: 29px;
text-decoration: none;
text-align: center;
line-height: 50px;
color: white !important;
font-size: 22px;
border-radius: 50%
}

.gotopbtn i {
color: white !important; /* Ensure the icon color stays white */
}
27 changes: 27 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,13 @@ <h5>Legal</h5>
</div>

</div>

<div id="topbtn" class="topbtn">
<a class="gotopbtn" href="#"><i class="fa-solid fa-angles-up"></i></a>
</div>



<div class="foot">
<div class="icons">
<div class="linkedin">
Expand Down Expand Up @@ -1033,6 +1040,26 @@ <h5>Legal</h5>
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<script src="main.js"></script>


<script>
const topButton = document.getElementById("topbtn");
window.onscroll = function () {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
topButton.style.display = "block";
} else {
topButton.style.display = "none";
}
};
topButton.onclick = function (event) {
event.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
};
</script>


</body>

</html>

0 comments on commit 555355a

Please sign in to comment.