Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back to Top button #108

Merged
merged 6 commits into from
Oct 3, 2024
Merged
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
39 changes: 37 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,41 @@ <h2 class="text-center" >Contact</h2>
&copy; Copyright <span id="year"></span>- All Rights Reserved
- Made With ❤️ by <span><a class="mygithub" href="https://github.com/aslams2020">Aslam Sayyad</a></span>
</p>
<button id="BacktoTop">
<div class="circle1">
<svg id="back-to-top" xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="currentColor" class="bi bi-arrow-up-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 0 0 8a8 8 0 0 0 16 0m-7.5 3.5a.5.5 0 0 1-1 0V5.707L5.354 7.854a.5.5 0 1 1-.708-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 5.707z"></path>
</svg>
</div>
</button>

</footer>

<script>
/* Back to Top Button */
const scrollToTopBtn = document.getElementById("BacktoTop");
window.onscroll = function() {
scrollFunction();
};

function scrollFunction() {
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
scrollToTopBtn.style.visibility = 'visible';
scrollToTopBtn.style.opacity = '1';
} else {
scrollToTopBtn.style.visibility = 'hidden';
scrollToTopBtn.style.opacity = '0';
}
}

scrollToTopBtn.addEventListener("click", function() {
// Smooth scroll back to top
window.scrollTo({ top: 0, behavior: 'smooth' });
});

</script>


<script>
window.addEventListener('scroll', function() {
const winScroll = document.body.scrollTop || document.documentElement.scrollTop;
Expand All @@ -112,8 +144,11 @@ <h2 class="text-center" >Contact</h2>
});

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

<script src="./Js/script.js"></script>
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script>
AOS.init();
</script>
</body>

</html>
Expand Down
45 changes: 45 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,48 @@ html{
color:rgb(247, 242, 242);
text-decoration: underline;
}
/* Back to Top button style */
#BacktoTop {
display: block; /* Ensure the button is part of the layout */
position: fixed;
bottom: 20px;
right: 20px;
width: 55px;
height: 55px;
background-color: rgb(170, 5, 5);
border-radius: 50%;
border: none;
cursor: pointer;
text-align: center;
line-height: 50px;
font-size: 24px;
z-index: 1000;
visibility: hidden;
opacity: 0;
transition: opacity 1.5s, visibility 1.5s, box-shadow 0.3s ease;
box-shadow: 0 0 0 2px #FFF, 0 0 0 3px #262626, 0 0 6px 2px rgba(255, 255, 255, 0.2); /* Adjusted outer rings */
overflow: hidden;
}

.circle1 {
display: flex;
align-items: center;
justify-content: center;
}

#BacktoTop:hover {
background-color: rgb(106, 12, 11); /* Darker shade on hover */
transform: scale(1.1); /* Slight zoom effect on hover */
}

#BacktoTop svg {
fill: #b4a933;
transition: fill 0.3s ease-in-out;
}

#BacktoTop:hover svg {
fill: #ffd700;
}