简体   繁体   English

在鼠标悬停的固定位置显示图像

[英]Show image on fixed location on mouse hover

I'm showing the results of a search and when I hover over an item I want to display an image on the top right corner of the website. 我正在显示搜索结果,当我将鼠标悬停在某个项目上时,我想在网站的右上角显示图像。 This is what I'm currently doing : 这是我目前正在做的事情

$name = '<a>' . $row['name'] . '<div><img src="' . 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=' . $row['multiverseid'] . '&type=card" /></div></a>';

That's making the website slow down because all the images are being loaded. 由于所有图像都已加载,这使网站变慢。 I want to load the images only on mouse hover like here . 我只希望在鼠标悬停加载图片喜欢这里

You can create every specific element on onmouseover event with Javascript when you want to display it. 如果要显示onmouseover事件,可以使用Javascript创建每个特定元素。 This will only load the image when the element is created. 仅在创建元素时才加载图像。 You can choose to delete it afterwards or hide it, and when needed load it again. 您可以选择随后删除它或隐藏它,并在需要时再次加载它。 You can find more about this event and how to use it here . 您可以在此处找到有关此事件的更多信息以及如何使用它。

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

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