javascript - 搜索时下拉列表向上移动
问题描述
当我在国家列表下拉列表中搜索国家时,我的 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:发行 gif
解决方案
如下添加到您的 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;
}
推荐阅读
- java - 如何根据用户输入声明变量?
- python - 如何获得一个函数来读取输入并定义它
- windows - 无法在 Windows Server 2012 上重新启动 Jenkins(正在使用的端口)
- redis - Redis Cluster - 无法建立连接Redis主从
- r - 左连接不重复相同的列
- php - 使用 find_files php 函数查找儿童文件夹
- linux - 相同版本的 jq 在 Ubuntu 16 和 Ubuntu 18 上的行为不同
- javascript - 如何将jinja2数据显示到javascript文件中
- bash - 如何为 sh 脚本中的前 n 个字节生成 MD5 哈希?
- java - 带有注释@PostConstruct(javax)的方法不会调用