2025-05-24

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
        <title>Insert title here</title>
  <script style="text/javascript">

   //商城 購物網,圖片放大程序
   window.onload = function(){
    var sImg = document.getElementById("sImg");
    var bImg = document.getElementById("bImg");
    var p = document.getElementById("p");
   
    sImg.onmousemove = function(){
     var xMove = event.x – 8;
     var yMove = event.y – 8;
    
     bImg.style.marginLeft = -xMove * 2;
     bImg.style.marginTop = -yMove * 2;
    }
    sImg.onmouseenter = function(){
     p.style.display = "block";
    }
    sImg.onmouseleave = function(){
     p.style.display = "none";  //為什麼不直接些none?
    }
   }
  </script>
    </head>
    <body>
     <img src="../img/beau.jpg" style="width:50px; height:70px" id="sImg"> 
  <!–為什麼要放到p中?–>
     <p style="border:1px solid; width:100px; height:140px; position:absolute; left:58px; top:78px; overflow:hidden;display:none" id="p">
  <img src="../img/beau.jpg" id="bImg">
     </p>
    </body>
</html>

 

摘自  代俊建的專欄 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *