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 1 commit
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
27 changes: 27 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ <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>


Expand All @@ -111,7 +119,26 @@ <h2 class="text-center" >Contact</h2>
document.getElementById('progress-bar').style.width = scrolled + '%';
});

/* 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.display = 'block'; // Show button
} else {
scrollToTopBtn.style.display = 'none'; // Hide button
}
}

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

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

</body>
Expand Down
42 changes: 42 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,45 @@ html{
color:rgb(247, 242, 242);
text-decoration: underline;
}
/* Back to Top button style */
#BacktoTop {
display: none; /* Initially hide the button */
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;
transition: transform 0.3s ease, 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;
}