【问题标题】:Drop down List is moving Up when searching搜索时下拉列表向上移动
【发布时间】:2020-12-27 17:56:27
【问题描述】:

当我在国家列表下拉列表中搜索国家时,我的 Angular 应用程序使用 ngx-intl-tel-input 库移动到顶部。我想在搜索时修复下拉菜单的位置。

演示:https://stackblitz.com/edit/ngx-intl-tel-input-demo-5u5c1p?file=src%2Fapp%2Fapp.component.ts

    <div style="margin: 50px">
  <br>

  <form #f="ngForm" [formGroup]="phoneForm">
    <div class="mb-2">
      <ngx-intl-tel-input 
        [cssClass]="'custom'" 
        [preferredCountries]="preferredCountries"
        [enableAutoCountrySelect]="true" 
        [enablePlaceholder]="true" 
        [searchCountryFlag]="true"
        [searchCountryField]="[SearchCountryField.Iso2, SearchCountryField.Name]"
        [selectFirstCountry]="false" 
        [selectedCountryISO]="CountryISO.India"
        [maxLength]="15" 
        [tooltipField]="TooltipLabel.Name" 
        [phoneValidation]="true" 
        [separateDialCode]="separateDialCode"
        name="phone" formControlName="phone">
      </ngx-intl-tel-input>
    </div>
    <div class="mb-2">
      <button (click)="f.reset()">Reset</button>
    </div>
  </form>
  <br>

</div>

GIF:Issue gif

【问题讨论】:

标签: javascript html css angular


【解决方案1】:

您的 html 页面包含溢出样式,因此在键入特定国家/地区时会向上滚动,因此您只需取消设置即可。

【讨论】:

    【解决方案2】:

    ngx-intl-tel-input 包更新到 2.5.0

    【讨论】:

      【解决方案3】:

      如下添加到您的 css 代码中,为框提供固定位置(使用 !important 防止覆盖)

      :host ngx-intl-tel-input  ::ng-deep .country-dropdown{
          left: 0px!important;
          right: auto!important;
          top: 100%!important;
          transform: translateY(0px)!important;
          bottom: auto!important;
      }
      

      SEE EXAMPLE

      【讨论】:

      • 告诉我更多帮助
      • 您好感谢您的快速响应,但问题尚未解决。滚动问题 GIF imgur.com/SgsxBpo
      • 您能否将 img/gif 附加到您的问题中(由于计算机的安全性,我无法打开它)
      猜你喜欢
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多