css - ng-select Angular2面板透明

标签 css angular colors

我的 ng-select css 有一些问题,我的下拉面板颜色在 Chrome 和 Firefox 上是透明的(通常默认颜色是白色)。

html

            <ng-select class="custom"[items]="mesurePoints2"
            bindLabel="name"
            bindValue="name"
            [ngModel]="actualMesurePoint.name"
            name="name"
             (ngModelChange)="mesurePointSelection($event)"
            >
           </ng-select>  

CSS

  .ng-select.custom {
  border:1px solid rgba(0, 0, 0, 0.15);
  height: 38px;
  border-radius: 0.25rem;
  background-color: white;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  font-family: sans-serif;
  }
  .ng-select.custom .ng-option {
  background-color: red;
  }

组件

@Component({
selector: 'app-traffic-data',
templateUrl: './traffic-data.component.html',
styleUrls: ['./traffic-data.component.scss', '../../../app.disabled.scss',
    '../../../../../node_modules/@ng-select/ng-select/themes/default.theme.css'],

最佳答案

您需要使用 encapsulation为了覆盖子组件的 css:

@Component({
selector: 'app-traffic-data',
templateUrl: './traffic-data.component.html',
styleUrls: ['./traffic-data.component.scss', '../../../app.disabled.scss',
    '../../../../../node_modules/@ng-select/ng-select/themes/default.theme.css'],
encapsulation: ViewEncapsulation.None
})

Example stackbiltz here .

关于css - ng-select Angular2面板透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49936647/

相关文章:

java - 图像上弹出文本的 CSS 帮助

angular - 如果 "ng serve"正在运行,站点不会自动重新加载

typescript - 如何使用 Gulp 和 SystemJS 捆绑 Angular 2 Typescript 应用程序?

r - R中的2d颜色渐变图

CSS:扩展为可折叠导航栏的流体布局

CSS 选择除 h1 之外的所有元素

java - 如何制作预设的唯一类对象

html - 如何改变<hr>标签的粗细和颜色?

javascript - 使用外部嵌入方式在我的简单 HTML 导航条码中嵌入 CSS 时出现问题

angular - 在 Typescript 中扩展构建器