Skip to content

Commit 4e770c9

Browse files
Merge pull request #93 from Sourojitbanerjee/main
Back to top issue fixed
2 parents 24edcc8 + bd74b02 commit 4e770c9

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ <h2>Projects</h2>
245245
</li>
246246
</ul>
247247
</div>
248+
248249

249250

250251
</div> <!-- /resume-sections -->
@@ -255,6 +256,8 @@ <h2>Projects</h2>
255256
</div>
256257
</div> <!-- /preview-section -->
257258
</div> <!-- /main-container -->
259+
<!-- back-to-top button -->
260+
<button class="back-to-top" id="backToTop" title="Back to Top"></button>
258261

259262
<footer style="margin-top: 2rem; padding: 1rem 0; text-align: center; font-size: 0.9rem;" class="footer">
260263
<div class="foot">
@@ -267,6 +270,7 @@ <h2>Projects</h2>
267270
</footer>
268271

269272

273+
270274
<script src="script.js" defer></script>
271275
</body>
272276
</html>

script.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,36 @@ toggle.addEventListener('click', () => {
343343
localStorage.setItem('theme', 'light');
344344
}
345345
});
346+
// back to top section
347+
const backToTopButton = document.getElementById('backToTop');
348+
349+
// Show/hide button based on scroll position
350+
window.addEventListener('scroll', function() {
351+
if (window.pageYOffset > 300) {
352+
backToTopButton.classList.add('show');
353+
} else {
354+
backToTopButton.classList.remove('show');
355+
}
356+
});
357+
358+
// Smooth scroll to top when button is clicked
359+
backToTopButton.addEventListener('click', function() {
360+
window.scrollTo({
361+
top: 0,
362+
behavior: 'smooth'
363+
});
364+
});
365+
366+
// Optional: Add keyboard support (Enter or Space key)
367+
backToTopButton.addEventListener('keydown', function(e) {
368+
if (e.key === 'Enter' || e.key === ' ') {
369+
e.preventDefault();
370+
window.scrollTo({
371+
top: 0,
372+
behavior: 'smooth'
373+
});
374+
}
375+
});
346376
// --- Draggable Resume Section Reordering ---
347377
document.addEventListener("DOMContentLoaded", () => {
348378
const container = document.getElementById("resume-sections");

style.css

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,70 @@ ul li ul {
490490
padding: 10px;
491491
}
492492
}
493-
493+
/* back-to-top button section */
494+
.back-to-top {
495+
position: fixed;
496+
bottom: 30px;
497+
right: 30px;
498+
background: linear-gradient(135deg, #2563eb, #3b82f6);
499+
color: white;
500+
border: none;
501+
border-radius: 50%;
502+
width: 60px;
503+
height: 60px;
504+
font-size: 24px;
505+
cursor: pointer;
506+
opacity: 0;
507+
visibility: hidden;
508+
transition: all 0.3s ease;
509+
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
510+
z-index: 1000;
511+
display: flex;
512+
align-items: center;
513+
justify-content: center;
514+
}
515+
516+
.back-to-top.show {
517+
opacity: 1;
518+
visibility: visible;
519+
transform: translateY(0);
520+
}
521+
522+
.back-to-top:hover {
523+
transform: translateY(-3px);
524+
box-shadow: 0 6px 20px rgba(0,0,0,0.3);
525+
background: linear-gradient(135deg,#1481ca);
526+
}
527+
528+
.back-to-top:active {
529+
transform: translateY(-1px);
530+
}
531+
532+
/* Arrow icon */
533+
.back-to-top::before {
534+
content: '↑';
535+
font-weight: bold;
536+
}
537+
538+
/* Responsive */
539+
@media (max-width: 768px) {
540+
.container {
541+
margin: 10px;
542+
border-radius: 0;
543+
}
544+
545+
.header, .section {
546+
padding: 20px;
547+
}
548+
549+
.back-to-top {
550+
bottom: 20px;
551+
right: 20px;
552+
width: 50px;
553+
height: 50px;
554+
font-size: 20px;
555+
}
556+
}
494557
@media print {
495558
.no-print {
496559
display: none;

0 commit comments

Comments
 (0)