Modals: preserve page scroll position while locking background

This commit is contained in:
2026-09-29 20:58:41 +03:00
parent 881bb6797a
commit d5fbb804c3
2 changed files with 15 additions and 5 deletions

View File

@@ -241,9 +241,12 @@ dialog.modal {
box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
dialog.modal::backdrop { background: rgba(0,0,0,0.55); }
/* Пока открыта модалка — страница не прокручивается; прокрутка остаётся внутри .modal-body */
html.modal-open, html.modal-open body { overflow: hidden; }
html.modal-open body { padding-right: var(--modal-scrollbar, 0); }
/* Пока открыта модалка — страница не прокручивается, позиция скролла сохраняется;
прокрутка остаётся внутри .modal-body */
html.modal-open body {
position: fixed; left: 0; right: 0; width: 100%; top: var(--modal-top, 0);
padding-right: var(--modal-scrollbar, 0);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border-bottom: 1px solid var(--c-border); }
.modal-title { margin: 0; font-size: 1.0625rem; font-weight: 600; }
.modal-close { border: none; background: none; cursor: pointer; font-size: 1.25rem; color: var(--c-text-muted); padding: 0 0.25rem; }