简体   繁体   English

无法在Angular Material的Select中更改样式

[英]Unable to change style in Angular Material's Select

I've been trying to make some style changes inside the overlay panel inside an Angular Material's MdSelect, in order to change max-width property (which is 280px by standard). 我一直在尝试在Angular Material的MdSelect中的叠加面板内进行一些样式更改,以便更改max-width属性(标准值为280px)。

I already tried everything, like overwriting the mat-select-panel class with '!important' attibutes, or using the panelClass Input (the class I'm passing through it appears inside the class attribute, but it doesn't seem to be taken into consideration). 我已经尝试了所有的东西,比如用'!important'attibutes覆盖mat-select-panel类,或者使用panelClass Input(我通过它的类出现在class属性中,但似乎没有采取考虑到)。

Has anyone been through the same issue? 有没有人经历过同样的问题? How can I solve this? 我怎么解决这个问题?

Thank you! 谢谢!

You can use the /deep/ instruction in your parent componenent's CSS. 您可以在父组件的CSS中使用/deep/指令。 See documentation here. 请参阅此处的文档

If the component you want to override the styles has : 如果要覆盖样式的组件具有:

  <div class="foo">...</div>

You can put in your parents or app css : 你可以放入你的父母或app css:

/deep/ .foo {
   [ ... ]
}

You can try set it in main css. 您可以尝试在主css中设置它。

.cdk-overlay-pane {
  .mat-select-panel {
    max-width: 700px;
  }

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM