下面我就为大家分享一篇javascript通过mouseover()实现图片变大效果的示例,具有很好的参考价值,希望对大家有所帮助
实例如下所示:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>图片提示</title> <!--jquery --> <script src="../jquery.min.js"type="text/javascript"></script> <style type="text/css"> body{ margin:0; padding:40px; background:#fff; font:80% arial, helvetica, sans-serif; color:#555; line-height:180%; } img{border:none;} ul,li{ margin:0; padding:0; } li{ list-style:none; float:left; display:inline; margin-right:10px; border:1px solid #aaaaaa; } /* tooltip */ #tooltip{ position:absolute; border:1px solid #ccc; background:#333; padding:2px; display:none; color:#fff; } </style> <script type="text/javascript"> $(document).ready(function(){ var x=1,y=1; var myhref; $("a[class=tooltip]").mouseover(function(e){//鼠标悬停的时候 myhref=this.href;//获取大图片 var $p=$("<p id='tooltip'><img src='"+myhref+"'></img></p>");//创建一个p $("body").append($p);//把p添加到body中 $("#tooltip").css({ top:e.pagey+y+"px", left:e.pagex+x+"px" }).show("slow"); }).mouseout(function(e){//鼠标移开的时候 $("#tooltip").remove(); }).mousemove(function(e){//鼠标移动的时候 $("#tooltip").css({ top:e.pagey+y+"px", left:e.pagex+x+"px" }).show("slow"); }) }); </script> </head> <body> <ul> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> </ul> <br/><br/><br/><br/> <br/><br/><br/><br/></body> </html>
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
在node.js中调用fs.renamesync出现报错问题?
使用npm创建vue项目(详细教程)
在node.js中用fs.rename如何实现强制重命名
以上就是在javascript中如何实现图片变大的详细内容。