使用 ng-select 时如何更改 css?

新手上路,请多包涵

我目前正在使用 ng-select 作为下拉菜单

<ng-select [items]="tests"
           (data)="signalChanged($event)"
           [active]="test"
           id="test)">
</ng-select>

我想更改下拉列表中活动元素的背景颜色。我如何访问它的css?

原文由 code1 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 417
1 个回答

您可以根据官方文档进行自定义。要找到您需要覆盖的确切类,请检查并识别该类。

 <ng-select class="custom"></ng-select>
.ng-select.custom {
    border:0px;
    min-height: 0px;
    border-radius: 0;
}
.ng-select.custom .ng-select-container  {
    min-height: 0px;
    border-radius: 0;
}

如果你使用 ViewEncapsulation,你应该使用特殊的 ::ng-deep 选择器,它会阻止嵌套选择器的作用域。

 .ng-select.custom ::ng-deep .ng-select-container  {
    min-height: 0px;
    border-radius: 0;
}

https://www.npmjs.com/package/@ng-select/ng-select#custom-styles 有更多相同的细节。

原文由 Chetan Laddha 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题