zoukankan      html  css  js  c++  java
  • 鼠标放在图片上图片跟随鼠标移动放大。 鼠标放在图片上图片放大

    跟随鼠标移动放大

    <!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> 
    <script language="javascript" src="file:///F|/phpStudy/WWW/fengzhuang/jquery-1.11.2.min.js"></script> 
    <script language="javascript"> 
    $(function(){ 
    var offsetX=20-$("#imgtest").offset().left; 
    var offsetY=20-$("#imgtest").offset().top; 
    var size=1.2*$('#imgtest img').width(); 
    $("#imgtest").mouseover(function(event) { 
    var $target=$(event.target); 
    if($target.is('img')) 
    { 
    $("<img id='tip' src='"+$target.attr("src")+"'>").css({ 
    "height":size, 
    "width":size, 
    "top":event.pageX+offsetX, 
    "left":event.pageY+offsetY, 
    }).appendTo($("#imgtest")); 
    } 
    }).mouseout(function() { 
    $("#tip").remove(); 
    }).mousemove(function(event) { 
    $("#tip").css( 
    { 
    "left":event.pageX+offsetX, 
    "top":event.pageY+offsetY 
    }); 
    }); 
    }) 
    </script> 
    <style type="text/css"> 
    img{ position:absolute;} 
    #imgtest{ height:auto;width:840px; margin:0 auto; position:absolute; }
    </style> 
    </head> 
    <body> 
    <div id="imgtest"> 
    <img src="FENDER芬达 011-3000.png"/>
    </div> 
    </body> 
    </html> 

    鼠标放在图片上图片放大

    <!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>
    </head>
    
    <body>
    
    <img id="img" onmouseover="bigger()" onmouseout="smaller()" src="1.jpg" style="cursor:pointer;100px;height:100px;" />
    <script type="text/javascript">
     var img = document.getElementById('img');
     function bigger(){
      img.style.width = '400px';
      img.style.height = '400px';
     }
     
     function smaller(){
      img.style.width = '100px';
      img.style.height = '100px';
     }
    
    </script>
    
    </body>
    </html>
  • 相关阅读:
    PHP面试:实现动态获取函数参数的方法
    PHP面试:什么是类的多态性,请写出一个例子
    php相关操作
    客户端app支付宝登录接口
    商品分类设计
    Git连接远程服务器
    iptables/mysql设置指定主机访问指定端口
    CMake安装grpc生成gRPCTargets.cmake文件
    Linux下Springboot解决`APR based Apache Tomcat Native library`提示
    java双重检测或枚举类实现线程安全单例(懒汉模式)
  • 原文地址:https://www.cnblogs.com/yyy251/p/6866339.html
Copyright © 2011-2022 走看看