拡大鏡(scrollTopベース)
2183 ワード
Document
![](7.jpg)
![](7.jpg)
var box=document.getElementById('box');
var bigbox=document.getElementById('bigbox');
box.onmousemove=function(en){
var e=en||window.event;
bigbox.style.display="block";
bigbox.style.left=box.offsetLeft+box.offsetWidth+5+'px';
bigbox.style.top=box.offsetTop+'px';
//
var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
var x=e.clientX-box.offsetLeft;
var y=e.clientY+scrollTop-box.offsetTop;
zoom.style.display="block";
// zoom
var left=Math.min(Math.max(x-50,0),300);
var top=Math.min(Math.max(y-50,0),200);
zoom.style.left=left+'px';
zoom.style.top=top+'px';
bigbox.scrollLeft=left*4;
bigbox.scrollTop=top*4;
}
box.onmouseout=function(){
bigbox.style.display="none";
zoom.style.display="none";
}