.mat-select-panel {
min-width: 180px !important;
max-width: 180px !important;
transform: translate(-2px, 44px) !important;
}
/* this will hide the element while it's being animated because
the animation happens for the original position */
.mat-select-panel.ng-animating {
display: none;
}
1 回答
不幸的是,您需要将
!important
添加到您添加的内容,因为角度材质会将位置添加为style
属性基本上,你需要添加\更改3个属性:
max-width - 如果内容较宽,则不允许选择更改
min-width - 相同
transform - 更改选择的位置
请注意,仍然存在从原始位置开始的动画放置 .
这是基本的变化:
将其添加到
styles.css
,因为此元素是在组件外部注入的 .演示:https://stackblitz.com/edit/angular-material-select-location?file=styles.css