Disable Scrolling for a Mat Dialog in the backdrop

Am trying to disable page scrolling when Mat Dialog is opened . Tried overflow:hidden but it didn't work . css3 dialogConfig = new MatDialogConfig(); dialogConfig.autoFocus = true; dialogConfig.backdropClass = "backdropBackground"; dialogConfig.hasBackdrop = true; dialogConfig.panelClass = "custom-dialog-container"; const dialogRef = this.dialog.open(ModalComponent, dialogConfig); style.css: .backdropBackground { background-color: rgba(0, 0, 0, 0.61); overflow: hidden; }
1 Reply
Wolle
Wolle11mo ago
The scrolling element needs to have overflow: hidden. You can check the scrolling element with document.scrollingElement (JS). It is usually the <html>.