首页 > 解决方案 > Material Angular 6中的单行水平芯片列表

问题描述

如何在 Material Angular 中创建一个水平滚动而不是占用多行的水平芯片列表?

标签: angulartypescriptangular-material

解决方案


这段代码解决了我们的问题:

(我们也在encapsulation: ViewEncapsulation.None我们的组件上使用过)。

::-webkit-scrollbar {
  height: 0;
}

div.mat-chip-list-wrapper {
  flex-wrap: nowrap;
  overflow-x: auto;
  width: 165px;
  white-space: nowrap;

  .mat-chip {
    flex: 0 0 auto;

    background: transparent;
    color: var(--white);
  }
}

.mat-chip-list {
  margin-left: 20px;
}

.mat-chip.mat-standard-chip .mat-chip-remove {
  color: var(--white);
}

推荐阅读