简体   繁体   English

在鼠标悬停时显示带有文本和图形的弹出窗口

[英]Display popup with text and graphics on mouse over

I want to have a popup window such that when the user hovers mouse over the image, it displays that popup window on the right of the image. 我想要一个弹出窗口,以便当用户将鼠标悬停在图像上时,它将在图像右侧显示该弹出窗口。 The window would contain text as well as graphics. 该窗口将包含文本和图形。 The window should close the moment my mouse is out of the image. 当鼠标移出图像时,窗口应关闭。 I tried various scripts that are on the internet, but they show the text as innerhtml of the same page. 我尝试了Internet上的各种脚本,但是它们将文本显示为同一页面的innerhtml。 So that breaks my original page. 这样就破坏了我的原始页面。 Is there a way to have a box with text and graphics come up when I roll over the image and go away when I close it? 有没有办法让我将鼠标悬停在图像上时将带有文本和图形的框抬起,并在关闭图像时使其消失?

Check out jQuery qtip -- http://craigsworks.com/projects/qtip/ 查看jQuery qtip- http://craigsworks.com/projects/qtip/

Demos: http://craigsworks.com/projects/qtip/demos/ 演示: http : //craigsworks.com/projects/qtip/demos/


Edit: Sample Code (straight from QTip's demo site). 编辑:示例代码(直接从QTip的演示站点)。 This will give the effect seen on http://craigsworks.com/projects/qtip/demos/content/basic 这将产生在http://craigsworks.com/projects/qtip/demos/content/basic上看到的效果

<script type="text/javascript" src="your/path/to/qtip.js"></script>
<script type="text/javascript">
// Create the tooltips only on document load
$(document).ready(function() 
{
   // Match all link elements with href attributes within the content div
   $('#content a[href]').qtip(
   {
      content: 'Some basic content for the tooltip' // Give it some content, in this case a simple string
   });
});
</script>

如果只需要捕获mouseover和mouseleave事件,也许如果目标浏览器允许的话,您应该只尝试在image或div上仅使用CSS和:hover选择器。

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

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