How to set max-height for the scroll bar in autoco

2019-08-15 19:44发布

问题:

I am using autocomplete component in my project, along with the autocomplete component i have added an button inside the component for adding a new customer as shown in below image.

Here i want to achieve 2 things:

1) I want to make button as fixed even after the scroll(i,e Add New Customer).

2) I want to reduce the height of the scroll bar. How can i do this? Here is the forked stackblitz link

回答1:

1) Use position:sticky:

.add-button{
  position: sticky;
    top: 0;
    z-index: 2;
}

2) Use height to .cdk-overlay-pane with ::ng-deep

::ng-deep .cdk-overlay-pane{
    height: 150px!important;}

See here:https://stackblitz.com/edit/angular-9ao75y-fc23aj?file=app/autocomplete-filter-example.css