Skip to content

Commit bd74b02

Browse files
back to top issue fixed
1 parent 8b04ee4 commit bd74b02

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
@@ -346,6 +346,36 @@ toggle.addEventListener('click', () => {
346346
localStorage.setItem('theme', 'light');
347347
}
348348
});
349+
// back to top section
350+
const backToTopButton = document.getElementById('backToTop');
351+
352+
// Show/hide button based on scroll position
353+
window.addEventListener('scroll', function() {
354+
if (window.pageYOffset > 300) {
355+
backToTopButton.classList.add('show');
356+
} else {
357+
backToTopButton.classList.remove('show');
358+
}
359+
});
360+
361+
// Smooth scroll to top when button is clicked
362+
backToTopButton.addEventListener('click', function() {
363+
window.scrollTo({
364+
top: 0,
365+
behavior: 'smooth'
366+
});
367+
});
368+
369+
// Optional: Add keyboard support (Enter or Space key)
370+
backToTopButton.addEventListener('keydown', function(e) {
371+
if (e.key === 'Enter' || e.key === ' ') {
372+
e.preventDefault();
373+
window.scrollTo({
374+
top: 0,
375+
behavior: 'smooth'
376+
});
377+
}
378+
});
349379
// --- Draggable Resume Section Reordering ---
350380
document.addEventListener("DOMContentLoaded", () => {
351381
const container = document.getElementById("resume-sections");

style.css

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,70 @@ body.dark .footer-link {
383383
margin-bottom: 0.5rem;
384384
display: block;
385385
}
386-
386+
/* back-to-top button section */
387+
.back-to-top {
388+
position: fixed;
389+
bottom: 30px;
390+
right: 30px;
391+
background: linear-gradient(135deg, #2563eb, #3b82f6);
392+
color: white;
393+
border: none;
394+
border-radius: 50%;
395+
width: 60px;
396+
height: 60px;
397+
font-size: 24px;
398+
cursor: pointer;
399+
opacity: 0;
400+
visibility: hidden;
401+
transition: all 0.3s ease;
402+
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
403+
z-index: 1000;
404+
display: flex;
405+
align-items: center;
406+
justify-content: center;
407+
}
408+
409+
.back-to-top.show {
410+
opacity: 1;
411+
visibility: visible;
412+
transform: translateY(0);
413+
}
414+
415+
.back-to-top:hover {
416+
transform: translateY(-3px);
417+
box-shadow: 0 6px 20px rgba(0,0,0,0.3);
418+
background: linear-gradient(135deg,#1481ca);
419+
}
420+
421+
.back-to-top:active {
422+
transform: translateY(-1px);
423+
}
424+
425+
/* Arrow icon */
426+
.back-to-top::before {
427+
content: '↑';
428+
font-weight: bold;
429+
}
430+
431+
/* Responsive */
432+
@media (max-width: 768px) {
433+
.container {
434+
margin: 10px;
435+
border-radius: 0;
436+
}
437+
438+
.header, .section {
439+
padding: 20px;
440+
}
441+
442+
.back-to-top {
443+
bottom: 20px;
444+
right: 20px;
445+
width: 50px;
446+
height: 50px;
447+
font-size: 20px;
448+
}
449+
}
387450
@media print {
388451
.no-print{
389452
display: none !important;

0 commit comments

Comments
 (0)