简体   繁体   English

如何在鼠标悬停和鼠标移开时保留和隐藏工具提示

[英]How to keep and hide tooltip on mouse hover and mouse out

I have igx-grid in which I am using igxTooltip .我有igx-grid ,我在其中使用igxTooltip When I am hovering on grid cell, and the tooltip is showing, and when I am going to hover on tooltip, it automatically hide.当我悬停在网格单元上时,工具提示正在显示,当我将悬停在工具提示上时,它会自动隐藏。 I want to make that to keep tooltip when I am hovering on tooltip and it should hide when mouse it out.当我将鼠标悬停在工具提示上时,我想让它保留工具提示,当鼠标移开时它应该隐藏。

This is I tried.这是我试过的。

Html code: html代码:

<div *ngIf="column.isTooltip">
  //cell of grid
  <div class="heightTarget" [igxTooltipTarget]="tooltipRef1">{{ value }}</div>
</div>
<div>
  <div #tooltipRef1="tooltip" igxTooltip>
    //this is tooltip which is showing
    <div class="poiterClass">{{ value }}</div>
  </div>
</div>

Css code: css代码:

.heightTarget {
  width: 130px;
  overflow: hidden;
  display: inline-block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pointerClass {
  display: none;
}

.pointerClass :hover {
  display: block;
}

Something like this?像这样的东西?

 var text = document.querySelector(".tooltip"); text.addEventListener("mouseover", function(){ text.querySelector(".tooltiptext").style.display = "block"; }); text.addEventListener("mouseout", function(){ text.querySelector(".tooltiptext").style.display = "none"; });
 tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; } .tooltip .tooltiptext { display:none; width: 120px; background-color: black; color: #fff; text-align: center; border-radius: 6px; padding: 5px 0; /* Position the tooltip */ position: absolute; z-index: 1; } .tooltip:hover .tooltiptext { visibility: visible; }
 <p>Move the mouse over the text below:</p> <div class="tooltip">Hover over me <span class="tooltiptext">Tooltip text</span> </div> <p>Note that the position of the tooltip text isn't very good. Go back to the tutorial and continue reading on how to position the tooltip in a desirable way.</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM