如何为Angular JS Auto Complete提供固定高度?

时间:2017-11-13 03:44:25

标签: javascript jquery html css angular

ng2-auto-complete结果很长。如果我尝试检查并给出一些css,当点击完成后,结果就会消失。然后我尝试了下面的一个样本,

ng2-auto-complete{
height: 400px; 
overflow-y: scroll; 
overflow-x: hidden;   
}

我认为这对我有用,但卷轴始终处于上述高度。如何解决这个bug。还有其他方法吗?

查看以下结果,该滚动始终存在。

检查下面的图像

enter image description here

检查以下代码

<div _ngcontent-c14="" class="form-group">
    <label _ngcontent-c14="">Language
        <span _ngcontent-c14="" class="required">*</span>
    </label>
    <div _ngcontent-c14="">
    <div class="ng2-auto-complete-wrapper" style="position: relative;">
        <input _ngcontent-c14="" class="form-control ng-valid ng-touched ng-dirty" display-property-name="TextField" name="ng2autoLanguage" ng2-auto-complete="" placeholder="Enter your language" value-property-name="ValueField" ng-reflect-klass="form-control" ng-reflect-ng-class="" ng-reflect-name="ng2autoLanguage" ng-reflect-source="function () { [native code] }" ng-reflect-display-property-name="TextField" ng-reflect-list-formatter="function (data) {
           " ng-reflect-model="" ng-reflect-ng-model="">
         </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

尝试使用max-height

ng2-auto-complete {
    max-height: 400px; 
    overflow-y: scroll; 
    overflow-x: hidden;   
}