【发布时间】:2022-04-22 20:46:27
【问题描述】:
我的 Angular html 模板中的选择组件显示正常。但是我想用红色边框显示这个组件,目前它以灰色显示。我无法做到这一点。
我正在使用 Angular 5
<ng-select class="custom" [searchable]="true" formControlName="contactList" [items]="contactLists"
bindLabel="name"
placeholder="{{ 'PLACEHOLDERS.CONTACT_LIST' | translate }}" [compareWith]="compareResource">
</ng-select>
自定义css在文件中定义,如下
.ng-select.custom {
min-height: 0px;
max-width: 350px;
}
.ng-select.dropdown {
border: 1px solid black;
}
【问题讨论】:
-
您是否尝试过在 css 中添加:!important 标志??
-
请您详细说明一下。应该在哪里放置 !important.. 谢谢
-
你应该像这样放置 !important: .ng-select.custom { min-height: 0px !important;最大宽度:350 像素!重要; } .ng-select.dropdown { 边框:1px 纯红色!重要; } 顺便说一句,我把你最后一行从“纯黑色”改为“纯红色”,因为你要求的是红色。
-
你能分享一下工作小提琴吗?谢谢
-
@prasanth 你可以使用一个不错的网站:stackblitz。这提供了一种共享代码的简单方法。
标签: angular css bootstrap-4 angular-ngselect