Angular 可滚动垫选择列表?
Angular scrollable mat-selection-list?
我有一个问题。我没有在堆栈上发现任何熟悉的问题所以我在这里问,是否可以使 <mat-selection-list>
可滚动(Angular 7)?当项目太多无法容纳 window.
时,我想在右侧显示滚动条
<mat-card fxFlex="33%">
<mat-selection-list>
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)"
>
</mat-list-item>
</mat-selection-list>
您可以试试:
<mat-card fxFlex="33%">
<mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)">
</mat-list-item>
</mat-selection-list>
通过设置自定义 CSS 属性?
CSS 只支持 Chrome 浏览器的精美滚动条:
.custom-scroll-bar{
height:70vh;
overflow-y:scroll;
overflow-x: hidden;
}
.custom-scroll-bar::-webkit-scrollbar{
width: 5px;
}
.custom-scroll-bar::-webkit-scrollbar-thumb{
background: rgba(0,0,0,.26);
}
对于 Firefox 和 Internet Explorer 只需简单地使用:
.custom-scroll-bar{
height:70vh;
overflow-y:scroll;
}
HTML:
<mat-selection-list #shoes class="custom-scroll-bar">
<mat-list-option *ngFor="let shoe of typesOfShoes">
{{shoe}}
</mat-list-option>
</mat-selection-list>
简单CSS
mat-selection-list {
max-height: 400px;
overflow: auto;
}
我有一个问题。我没有在堆栈上发现任何熟悉的问题所以我在这里问,是否可以使 <mat-selection-list>
可滚动(Angular 7)?当项目太多无法容纳 window.
<mat-card fxFlex="33%">
<mat-selection-list>
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)"
>
</mat-list-item>
</mat-selection-list>
您可以试试:
<mat-card fxFlex="33%">
<mat-selection-list [style.overflow]="'auto'" [style.height.px]="'300'">
<mat-list-item
*ngFor="let product of products"
[class.selected]="product === selectedproduct"
(click)="onSelect(product)">
</mat-list-item>
</mat-selection-list>
通过设置自定义 CSS 属性?
CSS 只支持 Chrome 浏览器的精美滚动条:
.custom-scroll-bar{
height:70vh;
overflow-y:scroll;
overflow-x: hidden;
}
.custom-scroll-bar::-webkit-scrollbar{
width: 5px;
}
.custom-scroll-bar::-webkit-scrollbar-thumb{
background: rgba(0,0,0,.26);
}
对于 Firefox 和 Internet Explorer 只需简单地使用:
.custom-scroll-bar{
height:70vh;
overflow-y:scroll;
}
HTML:
<mat-selection-list #shoes class="custom-scroll-bar">
<mat-list-option *ngFor="let shoe of typesOfShoes">
{{shoe}}
</mat-list-option>
</mat-selection-list>
简单CSS
mat-selection-list {
max-height: 400px;
overflow: auto;
}