【问题标题】:How to set max-height for the scroll bar in autocomplete component如何在自动完成组件中设置滚动条的最大高度
【发布时间】:2018-09-04 06:38:56
【问题描述】:

我在我的项目中使用 autocomplete 组件,连同自动完成组件,我在组件内添加了一个 button 用于添加新客户,如下图所示。

在这里我想实现两件事:

1) 我想让按钮在滚动后也固定不变(即添加新客户)。

2) 我想降低滚动条的高度。 我怎样才能做到这一点?这是分叉的stackblitz 链接

【问题讨论】:

    标签: angular angular-material


    【解决方案1】:

    1) 使用position:sticky:

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

    2) 使用height.cdk-overlay-pane::ng-deep

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

    请看这里:https://stackblitz.com/edit/angular-9ao75y-fc23aj?file=app/autocomplete-filter-example.css

    【讨论】:

    • 你拯救了我的一天,非常感谢。
    • 乐于助人:)
    • 还有一个帮助,请回答这个问题。https://stackoverflow.com/questions/52162800/display-the-value-of-a-selected-option-outside-the-input-field-in-chips-autocomp/52162952#52162952
    猜你喜欢
    • 1970-01-01
    • 2014-03-04
    • 2018-07-22
    • 1970-01-01
    • 2011-08-19
    • 2019-04-09
    • 1970-01-01
    • 2011-09-07
    • 1970-01-01
    相关资源
    最近更新 更多