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

Fixed Top Scroll across all pages #75

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
49 changes: 48 additions & 1 deletion 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);
}
#scrollBtn {
position: fixed;
bottom: 30px; /* Place closer to the bottom */
right: 30px; /* Place closer to the right */
display: none; /* Initially hidden */
background-color: #0d3cb4;
color: white;
border: none;
border-radius: 50%;
padding: 15px;
font-size: 18px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
z-index: 1000; /* Ensure visibility above other elements */
transition: background-color 0.3s ease, transform 0.3s ease;
}

#scrollBtn:hover {
background-color: #000; /* Change color on hover */
transform: scale(1.2); /* Slightly enlarge */
}
</style>
</head>
<body>
Expand Down Expand Up @@ -252,7 +273,10 @@
</label>
</div>
</div>
<footer class="main-footer">
<footer class="main-footer">
<button id="scrollBtn" title="Go to top">
<i class="fa-solid fa-arrow-up fa-lg"></i>
</button>
<div class="footer-content">
<div class="footer-section">
<h3>मातृबोधः</h3>
Expand Down Expand Up @@ -314,5 +338,28 @@ <h4>Contact Us</h4>
document.querySelector('.slide').prepend(items[items.length - 1])
})
</script>

<script>
// Get the button element
const scrollBtn = document.getElementById('scrollBtn');

// Show the button when the user scrolls down 100px from the top
window.onscroll = function () {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
scrollBtn.style.display = "block";
} else {
scrollBtn.style.display = "none";
}
};

// Scroll to the top of the page when the button is clicked
scrollBtn.onclick = function () {
window.scrollTo({
top: 0,
behavior: "smooth"
});
};

</script>
</body>
</html>
73 changes: 73 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,43 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>मातृबोधः</title>

<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="animations.css">
<link rel="stylesheet" href="scontentcss.css">
<link rel="stylesheet" href="footercss.css">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
/>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
</head>
<body>
<header>
<nav>
<!-- Wrap the logo text in an anchor tag -->
<a href="#hero" class="logo">मातृबोधः</a>
<ul class="nav-links">
<li><a href="#hero">Home</a></li>
<li><a href="#wisdom">About</a></li>
<li class="dropdown">
<a href="#">Content</a>
<ul class="dropdown-content">
<li><a href="countingpage.html">Counting</a></li>
<li><a href="#">Days</a></li>
<li><a href="#">Activities</a></li>
</ul>
</li>
</ul>
<a href="#" class="btn-contact">Contact</a>
</nav>
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="animations.css" />
<link rel="stylesheet" href="scontentcss.css" />
Expand Down Expand Up @@ -244,6 +281,17 @@ <h1>Heritage Map</h1>
</div>
</div>
</section>
<footer class="footer">

<button id="scrollBtn" title="Go to top">
<i class="fa-solid fa-arrow-up fa-lg"></i>
</button>

Made with <span class="heart">❤️</span> by
<a target="_blank" href="https://github.com/Anjaliavv51/Matrubodhah">
@Sakthi
</a>


<footer class="main-footer">
<div class="footer-content">
Expand Down Expand Up @@ -336,6 +384,31 @@ <h4>Contact Us</h4>
></script>
<script src="scrollscript.js"></script>
<script src="audio.js"></script>
<script>
// Get the button element
const scrollBtn = document.getElementById('scrollBtn');

// Show the button when the user scrolls down 100px from the top
window.onscroll = function () {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
scrollBtn.style.display = "block";
} else {
scrollBtn.style.display = "none";
}
};

// Scroll to the top of the page when the button is clicked
scrollBtn.onclick = function () {
window.scrollTo({
top: 0,
behavior: "smooth"
});
};

</script>
</body>
</html>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="index.js"></script>
Expand Down
24 changes: 24 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,30 @@ nav {

.wisdom-image {
max-width: 100%;
height: auto;
border-radius: 10px;
}

#scrollBtn {
position: fixed;
bottom: 120px; /* Place closer to the bottom */
right: 30px; /* Place closer to the right */
display: none; /* Initially hidden */
background-color: #0d3cb4;
color: white;
border: none;
border-radius: 50%;
padding: 15px;
font-size: 18px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
z-index: 1000; /* Ensure visibility above other elements */
transition: background-color 0.3s ease, transform 0.3s ease;
}

#scrollBtn:hover {
background-color: #000; /* Change color on hover */
transform: scale(1.2); /* Slightly enlarge */
margin: 30px 0;
}
}
Expand Down