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

Add top scroll button across all pages #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions countingpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@
.card[for="c10"]{
background-image: url(FOUR.png);
}

/* Scroll to Top Button */
#scrollToTopBtn {
display: none;
position: fixed;
bottom: 120px;
right: 37px;
height: 50px;
width: 50px;
background-color: rgb(218, 128, 76);
color: white;
border: none;
border-radius: 50%;
padding: 10px;
cursor: pointer;
font-size: 15px;
}

#scrollToTopBtn:hover {
background-color: rgb(218, 128, 76);
}
</style>
</head>
<body>
Expand Down Expand Up @@ -250,6 +271,9 @@
</label>
</div>
</div>

<button id="scrollToTopBtn" onclick="scrollToTop()">↑</button>

<footer class="main-footer">
<div class="footer-content">
<div class="footer-section">
Expand Down Expand Up @@ -298,6 +322,26 @@ <h4>Contact Us</h4>
<p>&copy; 2024 मातृबोधः. Made with <span class="heart">❤️</span> by <a href="https://github.com/Anjaliavv51/Matrubodhah" target="_blank">@Sakthi</a></p>
</div>
</footer>

<script>
// Get the button
let mybutton = document.getElementById("scrollToTopBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
};

// When the user clicks on the button, scroll to the top of the document
mybutton.onclick = function () {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
};
</script>
<script>
let next = document.querySelector('.next')
let prev = document.querySelector('.prev')
Expand Down
49 changes: 48 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@
<link rel="stylesheet" href="scontentcss.css">
<link rel="stylesheet" href="footercss.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
/* Scroll to Top Button */
/* Scroll to Top Button */
#scrollToTopBtn {
display: none;
position: fixed;
bottom: 120px;
right: 37px;
height: 50px;
width: 50px;
background-color: rgb(218, 128, 76);
color: white;
border: none;
border-radius: 50%;
padding: 10px;
cursor: pointer;
font-size: 15px;
}

#scrollToTopBtn:hover {
background-color: rgb(218, 128, 76);
}
</style>


</head>
<body>
<header>
Expand Down Expand Up @@ -84,7 +109,8 @@ <h1>Heritage Map</h1>
</div>
</div>
</section>

<button id="scrollToTopBtn" onclick="scrollToTop()">↑</button>

<footer class="main-footer">
<div class="footer-content">
<div class="footer-section">
Expand Down Expand Up @@ -137,5 +163,26 @@ <h4>Contact Us</h4>
<script src="//code.tidio.co/5w3m6cpl10rvqjkkmhv1nx8p0fqloyq6.js" async></script>
<script src="scrollscript.js"></script>
<script src="audio.js"></script>
<script>
// Get the button
let mybutton = document.getElementById("scrollToTopBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
};

// When the user clicks on the button, scroll to the top of the document
mybutton.onclick = function () {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
};
</script>


</body>
</html>
Loading