【发布时间】:2020-03-03 19:20:50
【问题描述】:
如果我有一个像这样的几个元素的网格行。每个元素都是带有mouseenter 函数的 col-lg-3。当 mouseenter 被触发时,我们显示带有“popover”类的 div,但考虑到 div 在 html 中的位置,它总是显示在行的末尾(for 循环)。我想显示与悬停的 div 直接相邻的类弹出框的 div。为此,我需要获取悬停元素的位置,并使用“popover”类调整 div 的 x、y 坐标、高度、宽度和其他 css 属性。关于如何使用 Renderer2 完成此操作的任何想法?
<div class="row">
<div class="card col-lg-3" *ngFor="let x of apples"
(mouseenter)="displayPopover()">
<div card-body">
stuff here
</div>
</div>
<div class="popover" *ngIf="showPopover">
<p>position me</p>
</div>
</div>
在我的打字稿文件中,我有一个这样的函数:
displayPopover() {
this.showPopover = true;
// dynamically position the popover next to the div that was hovered over
}
现在,
【问题讨论】:
标签: javascript html css angular typescript