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

added scroll to top button to all the pages #215

Merged
merged 1 commit into from
Oct 8, 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
4 changes: 4 additions & 0 deletions about-us.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ <h2 class="section-title">Contact Us</h2>

<div class="line"><br /></div>

<button id="backToTopBtn" title="Go to top"><i class="fa-solid fa-arrow-up"></i>
</button>
<script src="script.js"></script>

<footer class="footer">
<ul class="social-icon">
<li class="social-icon__item">
Expand Down
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,13 @@ <h3 class="name">Harrish M</h3>
<a href="https://www.instagram.com/h4ri_ig/" target="_blank"><i class="fa-brands fa-instagram"></i></a>
</div>
</div>



<!--Profiles-->
</div>

<button id="backToTopBtn" title="Go to top"><i class="fa-solid fa-arrow-up"></i>
</button>
<script src="script.js"></script>

<footer class="footer">
<ul class="social-icon">
<li class="social-icon__item"><a class="social-icon__link" href="https://m.facebook.com/profile.php?eav=AfaQiAnLMKoJt9fhAP0mpclv59dhzAMBnCy-rfJi2qawDv01IOkuI4RSxLQFG4508J0&paipv=0">
Expand Down
4 changes: 4 additions & 0 deletions project.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ <h3 class="name">Ashish</h3>
<!-- project -->
</div>

<button id="backToTopBtn" title="Go to top"><i class="fa-solid fa-arrow-up"></i>
</button>
<script src="script.js"></script>

<footer class="footer">
<ul class="social-icon">
<li class="social-icon__item"><a class="social-icon__link" href="https://m.facebook.com/profile.php?eav=AfaQiAnLMKoJt9fhAP0mpclv59dhzAMBnCy-rfJi2qawDv01IOkuI4RSxLQFG4508J0&paipv=0">
Expand Down
23 changes: 22 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,25 @@ darkMode.addEventListener("click", () => {
button.classList.toggle('bg-color');
});
});
});
});

// Get the button
let backToTopBtn = document.getElementById("backToTopBtn");

// Show the button when the user scrolls down 20px from the top of the document
window.onscroll = function() {
scrollFunction();
};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
backToTopBtn.style.display = "block";
} else {
backToTopBtn.style.display = "none";
}
}

// When the user clicks the button, scroll to the top of the document
backToTopBtn.onclick = function() {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
31 changes: 31 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,37 @@ footer {
color: black; /* Change text color to black on hover */
}

#backToTopBtn i {
font-size: 24px;
}

#backToTopBtn {
display: none; /* Hidden by default */
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
background-color: #444;
color: white;
border: none;
padding: 15px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
border-radius: 50%;
box-shadow: 5px 0px 10px 0px rgba(227, 86, 5, 0.838),-0.1em 0 0.4em rgba(227, 86, 5, 0.838);
transition: transform ease 0.5s, box-shadow ease 0.5s;

}

/* Button hover effect */
#backToTopBtn:hover {
background-color: #333;
transform: translateY(-5px);
box-shadow: 1px 10px 20px 2px rgba(227, 86, 5, 0.415);
}

/* Footer for About Page */
.about-footer {
background-color: var(
Expand Down
Loading