css - Angular Material 样式

标签 css angular-material angular6

我似乎可以使用 css 为 mat-option 字段上的滚动条设置样式。我想让滚动条具有不同的大小和颜色。任何帮助或指导将不胜感激。

我在下面尝试这样做,但没有成功。

How to change the scrollbar styles in Angular Material select?

  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
    <mat-option *ngFor="let product of filteredProducts | async" [value]="product">
      {{ product.name }}
    </mat-option>
  </mat-autocomplete>

最佳答案

要将样式应用于自动完成面板,您只需向自动完成元素添加一个类。请参阅“类”@Input 上的文档:https://material.angular.io/components/autocomplete/api#MatAutocomplete .

例如:

<mat-autocomplete class="custom-scroll" #auto="matAutocomplete" [displayWith]="displayFn">

然后在您的global scss 中:

.custom-scroll.mat-autocomplete-panel {

    &::-webkit-scrollbar {
        width: 8px;
    }

    &::-webkit-scrollbar-track {
        border-radius: 4px;
        background-color: green;
    }

    &::-webkit-scrollbar-thumb {
        border-radius: 4px;
        background-color: blue;
    }
}

关于css - Angular Material 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53102022/

相关文章:

css - 在CSS中创建自适应四边形梯形

html - Unblur 模糊背景 div 中的内容

angularjs - Angular Material 数据表搜索过滤器

angular - 在Angular 6中通过http get处理复杂对象

javascript - 如何根据文本长度使文本最适合?

css - 在循环结束时停止动画

angular - mat-icon 与 mat-select 位于 mat-tab 内

angular - 如何从 mat dialog 组件到实现 mat dialog 的组件进行通信?

javascript - 无法绑定(bind)到 'chartType',因为它不是 'canvas' 的已知属性

Angular/RxJS 6 : How to prevent duplicate HTTP requests?