Skip to content
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
22 changes: 21 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ window.addEventListener('DOMContentLoaded', () => {
let scrollPos = 0;
const mainNav = document.getElementById('navbar');
const headerHeight = mainNav.clientHeight;

// --- New: create back-to-top button ---
const backToTop = document.createElement('button');
backToTop.id = 'back-to-top';
backToTop.textContent = '↑ Top';
backToTop.title = 'Back to top';
backToTop.style.cssText = 'position:fixed; right:12px; bottom:72px; z-index:9999; padding:8px 10px; border-radius:8px; border:none; background:rgba(0,0,0,0.6); color:#fff; cursor:pointer; display:none;';
backToTop.addEventListener('click', () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
document.body.appendChild(backToTop);
// --- end new ---

window.addEventListener('scroll', function() {
const currentTop = document.body.getBoundingClientRect().top * -1;
if ( currentTop < scrollPos) {
Expand All @@ -18,6 +31,13 @@ window.addEventListener('DOMContentLoaded', () => {
mainNav.classList.add('is-fixed');
}
}
// show back-to-top when scrolled down enough
if (currentTop > 300) {
backToTop.style.display = 'block';
} else {
backToTop.style.display = 'none';
}

scrollPos = currentTop;
});
})
Expand Down Expand Up @@ -232,5 +252,5 @@ const attatchMobileMenuToggleFunction = () => {
};

document.addEventListener("DOMContentLoaded", function () {
attatchMobileMenuToggleFunction();
attachMobileMenuToggleFunction();
});
6 changes: 3 additions & 3 deletions style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ section {
z-index: 6;
}

.navbar-innner-parent {
.navbar-inner-parent {
position: relative;
width: 100%;
height: 5rem;
Expand Down Expand Up @@ -365,7 +365,7 @@ section {
margin-bottom: 0;
}
/*This is a form style for desktop*/
.discription-title {
.description-title {
display: grid;
grid-template-columns: 70% 30%;
}
Expand Down Expand Up @@ -642,7 +642,7 @@ footer .lag {
}
@media screen and (max-width: 1100px) {
/* This is a form style for desktop */
.discription-title {
.description-title {
display: flex;
flex-direction: column;
justify-content: center;
Expand Down