Rol*_*ndo 5 angular-material2 angular
我正在使用https://material.angular.io,特别是对话框(https://material.angular.io/components/dialog/overview)。我的问题是当我使用定位对话框时
config = {'width':'200px', 'height':'400px', position: {'top':'150px', 'left':'400px'}}
Run Code Online (Sandbox Code Playgroud)
我注意到,当我单击按钮显示对话框时,它会一直向下滚动...是否有某种方法可以使当我单击按钮显示对话框时,它保持在顶部/滚动到顶部?
将此代码添加到 style.css 文件中。
.md-dialog-container { height: 100vh !important; top: 0 !important; position: fixed !important; }
Run Code Online (Sandbox Code Playgroud)
其他方式:-
您可以使用 MdDialogRef 的 updatePosition() 方法调整对话框组件的位置。在您的对话框组件中使用此代码:-
import { MdDialog, MdDialogConfig, MdDialogRef } from '@angular/material';
constructor(public dialModalRef: MdDialogRef<any>) { }
changePosition() {
this.dialModalRef.updatePosition({ top: '50px', left: '50px' });
}
Run Code Online (Sandbox Code Playgroud)
在这里阅读更多相关信息:- https://material.angular.io/components/component/dialog
希望如此,一切顺利。
| 归档时间: |
|
| 查看次数: |
4799 次 |
| 最近记录: |