Is there a way to override the max-width of 80vw set on .mat-dialog-container
in an Angular Material dialog? I want to create a truly full-width dialog.
The issue lies with scoping--Angular-CLI compiles component CSS using scope attribute selectors.
This means that:
.parent .child
turns into:
.parent[some_attr] .child[some_other_attr]
However, this specific element appears not to be associated with any component—it lacks a dynamically-generated attribute.
https://i.sstatic.net/5Yl2S.png
I've tried overriding styles in both the dialog stylesheet and the host component's stylesheet without success.
Learn more about Angular special selectors
Check out the Dialog Plunkr example
Let me clarify further. I seem to be struggling to explain the problem adequately.
If I include the following in my host component stylesheet:
.mat-dialog-container {
max-width: 100%;
}
After recompiling the app due to a build watch running, the resulting CSS is as follows:
.mat-dialog-container[_ngcontent-c6] {
max-width: 100%;
}
Despite that, the element does not actually possess the _ngcontent-c6
attribute. This attribute is assigned to other elements within siblings or ancestors of .mat-dialog-container
. The selector is incorrect.
If I apply the CSS to the dialog component's stylesheet, a similar situation occurs, but with a different attribute ID.