gpt4 book ai didi

css - 谷歌自动完成下拉位置问题

转载 作者:行者123 更新时间:2023-12-04 03:49:57 27 4
gpt4 key购买 nike

我正在使用 NgxAutocomPlace我的 Angular 应用程序中的模块,以下模块通过生成 .pac-container 与谷歌自动完成 API 一起工作其中显示自动完成结果。

问题在于,在移动设备上,下拉菜单位于输入上方而不是下方,最终用户无法使用,它看起来像这样:

enter image description here

这是我的代码的样子:

<div class="container-indirizzo mb-3">
<label>Indirizzo di consegna</label>
<div class="inside-indirizzo">
<div class="indirizzo">
<input
*ngIf="addressOptions !== null"
type="text"
class="form-control"
required
placeholder="es. Via Disraeli"
formControlName="indirizzo"
ngxAutocomPlace
[options]="addressOptions"
(selectedPlace)="addressChange($event)"
/>
</div>
<div class="civico" *ngIf="isCivico">
<input type="text" class="form-control" formControlName="nciv" placeholder="N°" autofocus />
</div>
</div>
</div>

有没有办法在 <input> 下设置下拉菜单的位置? ?

编辑 1:

当虚拟键盘启动时,问题发生在滚动或移动设备上,所以问题是触发时设置为 pac-container 的位置

编辑 2:

我正在尝试在地址更改和滚动时做类似的事情,但即使这样也没有任何效果:

 const top = this.indirizzo.nativeElement.getBoundingClientRect().top ;
const pacContainer = document.querySelector('.pac-container') as HTMLElement;
if (pacContainer) {
console.log(window.scrollY + top + 60);
pacContainer.style.top = window.scrollY + top + 60;
}

其中 indirizzo 是放置输入的 Div。

编辑 3:

.pac 容器是在 <body> 下生成的所以我认为通过强制它在 <div class="indirizzo"> 下呈现将解决问题...

编辑 4:

已解决 通过将 pac-container 设置为从屏幕顶部到输入底部的 X 像素的固定位置,但仍在寻找更好的解决方案。

(因此从顶部 0 到我输入的末尾有 465px 我刚刚设置了 .pac-container top: 465px )但是在某些屏幕上高度可能会更低(一些移动设备 450 一些其他 460 其他 470)下拉菜单仍然绘制得很糟糕..

最佳答案

如果您使用的是 Angular Material ,这将有所帮助

.pac-container {
z-index: 100000;
}

如果您正在使用 Bootstrap,这会对您有所帮助。

::ng-deep .pac-container {
z-index: 100000;
}

关于css - 谷歌自动完成下拉位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64558055/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com