六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 59|回复: 0

图片移动不超出边界

[复制链接]

升级  25.33%

24

主题

24

主题

24

主题

秀才

Rank: 2

积分
88
 楼主| 发表于 2013-1-27 05:46:05 | 显示全部楼层 |阅读模式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE>图片移动</TITLE><META http-equiv=keywords content=keyword1,keyword2,keyword3><META http-equiv=description content="this is my page"><META http-equiv=content-type content="text/html; charset=UTF-8"><SCRIPT language=javascript type=text/javascript>  var mouseObj=null;var pX;var pY;document.onmousemove=divMove;document.onmouseup=divUp;  function m(c_Obj){ mouseObj=document.getElementById(c_Obj);// mouseObj.style.position="absolute"; pX=mouseObj.style.pixelLeft-event.x; pY=mouseObj.style.pixelTop-event.y;} function divMove(){if(mouseObj){mouseObj.style.cursor="move";mouseObj.style.left=pX+event.x;mouseObj.style.top=pY+event.y;event.returnValue=false;} }function divUp() {if(mouseObj){mouseObj.style.cursor="hand";mouseObj=null;}}</SCRIPT><STYLE>.div {BORDER-RIGHT: #000 1px solid; BORDER-TOP: #000 1px solid; OVERFLOW-Y: hidden; BACKGROUND: lightblue; OVERFLOW-X: hidden; PADDING-BOTTOM: 0px; BORDER-LEFT: #000 1px solid; WIDTH: 600px; BORDER-BOTTOM: #000 1px solid; HEIGHT: 800px}</STYLE></HEAD><BODY><DIV class=div id=imgDiv><IMG onmousedown="m('layer');" id=layer style="POSITION: absolute;background:red;"  src="11.jpg"> </DIV></BODY></HTML>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表