Я пытаюсь расположить модуль MatSnackbar
так, чтобы он отображался вверху моей страницы.
Я пытался использовать config
для добавления customclass
. Вот мой код:
component.ts
let config = new MatSnackBarConfig();
config.duration = 50000;
config.panelClass = ['red-snackbar']
this.snackBar.open("Please fill all the details before proceeding.", null, config);
< Сильный > .css
.red-snackbar{
position: absolute !important;
top: 54px;
}
Но это не работает. Можно ли переместить MatSnackbar?
3 ответа
Вы можете определить verticalPosition: MatSnackBarVerticalPosition
в соответствии с документами.
Ts:
openSnackBar(message: string, action: string) {
this.snackBar.open(message, action, {
duration: 2000,
// here specify the position
verticalPosition: 'top'
});
}
Для позиционирования закусочной используйте значения положения
this.snackBar.open(message.text, action, {
duration: this.timeOut,
verticalPosition: 'bottom', // 'top' | 'bottom'
horizontalPosition: 'end', //'start' | 'center' | 'end' | 'left' | 'right'
panelClass: ['red-snackbar'],
});
И чтобы изменить цвет, в вашем style.css определите red-snackbar:
.red-snackbar{
background-color: rgb(153, 50, 50);
color:lightgoldenrodyellow;
}
https://www.coditty.com/code/angular-material-display-multiple-snackbars-messages-in-sequence
Это должно работать:
.mat-snack-bar-container {
margin-top: 50px !important;
}
Похожие вопросы
Новые вопросы
angular
Вопросы по Angular (не путать с AngularJS), веб-фреймворку от Google. Используйте этот тег для угловых вопросов, которые не относятся к конкретной версии. Для более старой веб-платформы AngularJS (1.x) используйте тег angularjs.