【发布时间】:2019-09-22 07:55:57
【问题描述】:
我有角形项目,我从角形材料添加底部片材,它可以工作。 我试图让打开的弹出窗口粘在按钮上并响应他但它不起作用。
我的主要组件:
import { Component, OnInit } from '@angular/core';
import { MatBottomSheet } from '@angular/material/bottom-sheet';
import { PopupsDialogComponent } from '../../../modules/home/components/popups-dialog/popups-dialog.component';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.sass']
})
export class HeaderComponent implements OnInit {
constructor(private _bottomSheet: MatBottomSheet) { }
ngOnInit() {
}
openBottomSheet(): void {
this._bottomSheet.open(PopupsDialogComponent, {
panelClass: 'custom-popup'
});
}
}
主要组件html: 这是我希望对话框对他来说很粘的按钮
<header>
<div class="container">
<button mat-fab class="mat-success" (click)=openBottomSheet()>+</button>
</div>
</header>
PopupsDialogComponents:
import { Component } from '@angular/core';
import {MatBottomSheetRef} from '@angular/material/bottom-sheet';
@Component({
selector: 'app-popups-dialog',
templateUrl: './popups-dialog.component.html',
styleUrls: ['./popups-dialog.component.sass']
})
export class PopupsDialogComponent {
constructor(private _bottomSheetRef: MatBottomSheetRef<PopupsDialogComponent>) {}
openLink(event: MouseEvent): void {
this._bottomSheetRef.dismiss();
event.preventDefault();
}
}
style.css:
.custom-popup
position: absolute
top: 95px
right: 26%
min-width: 0% !important
非常感谢
【问题讨论】:
-
你是否在你的主 sass/css 文件中导入了以下内容?(src/style.sass 或 css)
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css' -
你将样式应用到 top:95px 所以它会被定位在那里,有什么问题?
-
哦,你的意思是按钮不是底部......(你的问题有一些错误)。我在几行中添加了 src/main.css
.mat-bottom-sheet-container{ position: fixed !important; top: 27px !important; left: 0px !important; } -
当我调整屏幕大小时,弹出窗口获得新位置;(
-
代替固定使用绝对
标签: css angular sass angular-material