简体   繁体   English

将鼠标悬停在图像上时如何放大图像?

[英]How to enlarge image while hover over an image?

I want to show the thumbnail image large when hover over it, similar to the one in 我希望将鼠标悬停在缩略图上时将其放大显示,类似于

http://www.freelayouts.com/websites/html-templates Plz help. http://www.freelayouts.com/websites/html-templates Plz帮助。 Any help will be appreciated. 任何帮助将不胜感激。

What you need is a tooltip plugin. 您需要的是一个工具提示插件。 There are plenty of them. 有很多。 Check out this list: https://cssauthor.com/jquery-css3-hover-effects/ 查看此列表: https : //cssauthor.com/jquery-css3-hover-effects/

<img class="enlarge-onhover" src="img.jpg">

...

And on the css:

.enlarge-onhover {
     width: 30px;
     height: 30px;
}

.enlarge-onhover:hover {
     width: 70px;
     height: 70px;
}

Take a look at http://fancybox.net/blog 看看http://fancybox.net/blog

Fancybox looks nice, uses JQuery and is highly configurable with various show/hide effects. Fancybox看起来不错,使用JQuery,并且可以通过各种显示/隐藏效果进行高度配置。 Tutorial number 3 on this page shows you how to use it OnHover rather than OnClick 本页上的教程3向您展示如何在OnHover而不是OnClick上使用它

The home page http://fancybox.net/home shows some examples of the visual effect 主页http://fancybox.net/home展示了一些视觉效果的示例

<script>
function bigImg(x) {
   x.style.height = "64px";
   x.style.width = "64px";
}

function normalImg(x) {
   x.style.height = "32px";
   x.style.width = "32px";
}
</script>

<img onmouseover="bigImg(this)" onmouseout="normalImg(this)" border="0" src="smiley.gif" alt="Smiley" width="32" height="32">

The function bigImg() is triggered when the user mouse over the image. 用户将鼠标悬停在图像上时,将触发bigImg()函数。 This function enlarges the image. 此功能放大图像。

The function normalImg() is triggered when the mouse pointer is moved out of the image. 当鼠标指针移出图像时,将触发normalImg()函数。 That function sets the height and width of the image back to normal. 该功能将图像的高度和宽度设置为正常。

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

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