我可以设置bottomsheet的宽度在角材料2(固定或百分比)?
非常感谢
使用panelClass
配置参数。例如:
在styles.css
:(全局样式文件,而不是component.css
文件)
.custom-width {
width: 450px;
}
In your component.ts
:
this.bottomSheet.open(BottomSheetOverviewExampleSheet, {
panelClass: 'custom-width'
});
https://stackblitz.com/angular/qvokqxjgbrn
注意:只有宽度像素将正常工作。
除了Tabrez Ahmeds出色答卷:如果要设置宽度分别100%
100vw
您需要添加以下在styles.css中,避免左右的空间:
.custom-width {
width: 100vw;
}
.mat-bottom-sheet-container-large, .mat-bottom-sheet-container-medium, .mat-bottom-sheet-container-xlarge {
/* unset maximum width */
max-width: unset !important;
}
.mat-bottom-sheet-container-large, .mat-bottom-sheet-container-medium, .mat-bottom-sheet-container-xlarge {
/* remove border radius */
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}