• js鼠标滑过小图显示大图效果


    <style>
    #demo img{border:none;100px;height:100px; margin-right:20px;}
    #enlarge_images{position:absolute;display:none;z-index:2;border:5px solid #f4f4f4}
    </style>
    <div id="demo" style="overflow:hidden;height:100px; 1000px;">
     <img src="content/images/88888.png"><img src="content/images/88888.png"><img src="content/images/88888.png">
    </div>
    <div id="enlarge_images"></div>
    <script>
    var demo = document.getElementById("demo");
    var gg = demo.getElementsByTagName("img");
    var ei = document.getElementById("enlarge_images");
    for(i=0; i<gg.length; i++){
     var ts = gg[i];
     ts.onmousemove = function(event){
      event = event || window.event;
      ei.style.display = "block";
      ei.innerHTML = '<img src="' + this.src + '" style=" 200px; height:200px;" />';
      ei.style.top  = document.body.scrollTop + event.clientY + 10 + "px";
      ei.style.left = document.body.scrollLeft + event.clientX + 10 + "px";
     }
     ts.onmouseout = function(){
      ei.innerHTML = "";
      ei.style.display = "none";
     }
     ts.onclick = function(){
      window.open( this.src );
     }
    }
    </script>

  • 相关阅读:
    git 常用命令
    最近任务 && react文章列表
    markdown 常用格式API
    webpack 插件怎么写
    iframe
    重置浏览器滚动条css
    webpack4
    vscode插件开发
    vscode插件
    react router 的push replace
  • 原文地址:https://www.cnblogs.com/dearxinli/p/2937246.html
Copyright © 2020-2023  润新知