fix: Perfect modal centering on mobile (portrait and landscape)
Fixes info modal positioning to be perfectly centered on mobile devices in all orientations. ISSUE: - Info modal was not centered on mobile viewports - User reported "pop-up of information in mobile it is not centered" - Modal positioning relied on inset:0 + margin:auto which doesn't work consistently on mobile devices FIX: - Added explicit mobile centering using transform translate(-50%, -50%) - Position: top: 50%, left: 50% with transform centering - Applied to all modals: info, keyboard shortcuts, and PDF download - Added mobile-specific fade-in animation preserving centering - Constrained modal to viewport with calc(100vw - 2rem) width/height Files modified: - static/css/04-interactive/_modals.css - Mobile centering for all modals - tests/mjs/58-modal-centering-test.mjs - Validation test Test results: ✅ Portrait (375×667): Perfect center - 0px offset ✅ Landscape (667×375): Perfect center - 0px offset ✅ Modal center matches viewport center exactly
This commit is contained in:
@@ -41,6 +41,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Mobile-specific fade-in animation with translate centering */
|
||||
@keyframes modalFadeInMobile {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -50%) scale(0.9);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.info-modal-content {
|
||||
background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
|
||||
backdrop-filter: blur(20px);
|
||||
@@ -232,9 +244,30 @@
|
||||
|
||||
/* Mobile responsive */
|
||||
@media (max-width: 768px) {
|
||||
/* Force perfect centering on mobile */
|
||||
.info-modal {
|
||||
position: fixed !important;
|
||||
top: 50% !important;
|
||||
left: 50% !important;
|
||||
right: auto !important;
|
||||
bottom: auto !important;
|
||||
transform: translate(-50%, -50%) !important;
|
||||
margin: 0 !important;
|
||||
max-width: calc(100vw - 2rem) !important;
|
||||
width: calc(100vw - 2rem) !important;
|
||||
max-height: calc(100vh - 2rem) !important;
|
||||
}
|
||||
|
||||
/* Animation adjusted for mobile centering */
|
||||
.info-modal[open] {
|
||||
animation: modalFadeInMobile 0.3s ease;
|
||||
}
|
||||
|
||||
.info-modal-content {
|
||||
padding: 2rem 1.5rem;
|
||||
max-width: calc(100% - 2rem);
|
||||
max-width: 100%;
|
||||
overflow-y: auto;
|
||||
max-height: calc(100vh - 2rem);
|
||||
}
|
||||
|
||||
.info-modal-header h2 {
|
||||
@@ -402,7 +435,9 @@
|
||||
/* Mobile responsive */
|
||||
@media (max-width: 768px) {
|
||||
#shortcuts-modal {
|
||||
max-width: calc(100% - 2rem);
|
||||
max-width: calc(100vw - 2rem) !important;
|
||||
width: calc(100vw - 2rem) !important;
|
||||
max-height: calc(100vh - 2rem) !important;
|
||||
}
|
||||
|
||||
#shortcuts-modal .info-modal-body {
|
||||
@@ -753,11 +788,11 @@
|
||||
|
||||
/* Mobile: Single column - Button-like style */
|
||||
@media (max-width: 768px) {
|
||||
/* Mobile centering is now handled via JavaScript in openPdfModal() */
|
||||
/* This CSS provides fallback styling for mobile screens */
|
||||
|
||||
/* Mobile centering - consistent with info modal */
|
||||
.pdf-download-modal {
|
||||
max-width: calc(100% - 1rem);
|
||||
max-width: calc(100vw - 2rem) !important;
|
||||
width: calc(100vw - 2rem) !important;
|
||||
max-height: calc(100vh - 2rem) !important;
|
||||
}
|
||||
|
||||
/* Reduce modal padding on mobile */
|
||||
|
||||
Reference in New Issue
Block a user