【发布时间】:2020-08-20 02:55:00
【问题描述】:
我正在使用 angular 中的 mat-select。我在 2 个地方使用过它。
- 应用组件
- 模态组件
为了在 mat-select 中设置选项面板的样式,我使用了 ng-deep,如下所示,
在 app.component.css 中
::ng-deep .mat-select-panel {
border-top: none !important;
min-width: 100% !important;
position: absolute;
box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.15);
margin-left: 17px !important;
margin-top: -10px !important;
}
在将另一个模态元素添加到页面之前,它的位置是正确的。在这个模态组件中,ng-deep 也被用于在模态中设置 mat-select 的样式。 在modal.component.css
::ng-deep .mat-select-panel {
min-width: calc(100% + 7px) !important;
position: absolute;
top: 100px;
left: 20px;
}
所以现在当我们点击modal组件中的mat-select,然后如果我们点击app组件中的mat-select,app组件中mat-select的位置似乎在不同的位置。 谁能帮我解决这个问题。
【问题讨论】:
-
您是否尝试添加 div 并将您的 mat 面板放入其中并写为 .yourelement ::ng-deep
标签: css angular angular-material