2008-04-26

div resize

http://topic.csdn.net/t/20030522/16/1819974.html
引用

  <html>  
  <head>  
      <title>div   test</title>  
  <script   language="javascript">  
  var   mouseX   =   0;  
  var   mouseY   =   0;  
   
  function   divonmousemove(obj)  
  {  
  if   ((Math.abs(obj.offsetLeft+obj.offsetWidth-event.x)<4)   &&   (Math.abs(obj.offsetTop+obj.offsetHeight-event.y)<4))  
                  obj.style.cursor='se-resize';  
          else   if   (Math.abs(obj.offsetLeft+obj.offsetWidth-event.x)<4)   obj.style.cursor='e-resize';  
          else   if   (Math.abs(obj.offsetTop+obj.offsetHeight-event.y)<4)   obj.style.cursor='s-resize';  
          else  
          obj.style.cursor='';  
          if   (event.button==1)  
          {  
                  obj.style.width   =   parseInt(obj.offsetWidth)   +   (event.x   -   mouseX);  
  mouseX   =   event.x;  
                  obj.style.height   =   parseInt(obj.offsetHeight)   +   (event.y   -   mouseY);  
  mouseY   =   event.y;  
          }  
  }  
   
  function   divonmousedown(obj)  
  {  
  mouseX   =   event.x;  
          mouseY   =   event.y;  
  }  
   
  function   divonmouseup(obj)  
  {  
  mouseX   =   0;  
          mouseY   =   0;  
  }  
  </script>  
  </head>  
  <body align="center">  
  <div   onmousemove="divonmousemove(this);"   onmouseleave="this.style.cursor='';"  
  onmousedown="divonmousedown(this);"   onmouseup="divonmouseup(this);"  
    style="width:100px;;height:200;background:green;float:left;"   title="按下鼠标拖动大小">  
xxxxxxxxxxxxx  
  </div>  

  <div   onmousemove="divonmousemove(this);"   onmouseleave="this.style.cursor='';"  
  onmousedown="divonmousedown(this);"   onmouseup="divonmouseup(this);"  
    style="width:100px;height:200;background:red;float:left;"   title="按下鼠标拖动大小">  
yyyyyyyyyyyyyy 
  </div>

<div   onmousemove="divonmousemove(this);"   onmouseleave="this.style.cursor='';"  
  onmousedown="divonmousedown(this);"   onmouseup="divonmouseup(this);"  
    style="width:100px;height:200;background:blue;float:left;"   title="按下鼠标拖动大小">  
yyyyyyyyyyyyyy 
  </div>

<div   onmousemove="divonmousemove(this);"   onmouseleave="this.style.cursor='';"  
  onmousedown="divonmousedown(this);"   onmouseup="divonmouseup(this);"  
    style="width:100px;height:200;background:#EDEDDD;float:left;"   title="按下鼠标拖动大小">  
yyyyyyyyyyyyyy 
  </div>
  </body>  
  </html>
评论
发表评论

您还没有登录,请登录后发表评论

right now
搜索本博客
博客分类
最近加入圈子
最新评论
评论排行榜