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 .
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;
}
![css3](https://cdn.discordapp.com/emojis/860914920065597450.png)
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1138762207149166592/image.png)
1 Reply
The scrolling element needs to have
overflow: hidden
. You can check the scrolling element with document.scrollingElement
(JS). It is usually the <html>
.