135-1821-9792

jquery调整大小(resizable)

 看着jquery的大小收缩,自己也尝试写了一个,其实就是增加了三个div来控制大小。

目前创新互联公司已为上1000+的企业提供了网站建设、域名、虚拟空间、绵阳服务器托管、企业网站设计、郴州网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

jquery调整大小(resizable)效果图

  1.  
  2.  
  3.  
  4.  
  5. resizable 
  6.  
  7. body{    
  8.   -moz-user-focus:ignore;    
  9.   -moz-user-input:disabled;    
  10.   -moz-user-select:none;    
  11. }      
  12. .ui-resizable-bd{ 
  13.     background:none; 
  14.     position: absolute; 
  15.     z-index: 1000; 
  16. .ui-resizable-bd-east{ 
  17.     cursor: e-resize; 
  18. .ui-resizable-bd-south{ 
  19.     cursor: s-resize; 
  20. .ui-resizable-bd-corner{ 
  21.     width:16px; 
  22.     height:16px; 
  23.     cursor: nw-resize; 
  24. /*  右下角小图标 */ 
  25.     background: url(p_w_picpaths/resizable.JPG) no-repeat;  
  26.  
  27.  
  28.  
  29.  
  30.      
  31.          
  32.     
 
  •  
  •   
  •  
  • /** 
  •  * jquery resizable 
  •  * @author huxiaoqi 
  •  */ 
  • (function($){ 
  •     $.fn.resizable = function(cfg){ 
  •         var self = $(this); 
  •         var BD_E = $("
  • "); 
  •         var BD_S = $(""); 
  •         var BD_SE = $(""); 
  •         var WIDTH = self.width(); 
  •         var HEIGHT = self.height(); 
  •         var pos = self.offset(); 
  •         var BD_WIDTH = 3;   //default border width 
  •         var documentObj = $(document); 
  •         var bodyObj = $('body',documentObj); 
  •         /* 
  •          * 定义缩放最小值 
  •          */ 
  •         var _default = {                     
  •                             minwidth:50, 
  •                             minheight:50 
  •                         }; 
  •         var config = $.extend({},_default,cfg); 
  •         //放入节点 
  •         BD_E.insertAfter(self); 
  •         BD_S.insertAfter(self); 
  •         BD_SE.insertAfter(self); 
  •         setBDPos(WIDTH, HEIGHT, pos.left, pos.top); 
  •         documentObj.bind({ 
  •             'mousedown':function(e){ 
  •                 if(isBD(e.target)){ 
  •                     var currentTarget = e.target; 
  •                     var className = currentTarget.className; 
  •                     documentObj.bind('mousemove',function(e){ 
  •                         pos = self.offset(); 
  •                         WIDTH = self.width(); 
  •                         HEIGHT = self.height(); 
  •                         var width = e.pageX - pos.left; 
  •                         var height = e.pageY - pos.top; 
  •                         if(className.indexOf('bd-east') != -1){ 
  •                             /* 
  •                              * east border 
  •                              */                          
  •                             if(width > config.minwidth ){ 
  •                                 self.width(width); 
  •                                 setBDPos(width, HEIGHT, pos.left, pos.top); 
  •                             } 
  •                             bodyObj.css('cursor','e-resize'); 
  •                         } 
  •                         else if(className.indexOf('bd-south') != -1){ 
  •                             /* 
  •                              * south border 
  •                              */ 
  •                             if(height > config.minheight ){ 
  •                                 self.height(height); 
  •                                 setBDPos(WIDTH, height, pos.left, pos.top); 
  •                             } 
  •                             bodyObj.css('cursor','s-resize'); 
  •                         } 
  •                         else if(className.indexOf('bd-corner') != -1){ 
  •                             /* 
  •                              * south-east border 
  •                              */ 
  •                             if(width > config.minwidth && height > config.minheight){ 
  •                                 self.width(width); 
  •                                 self.height(height); 
  •                                 setBDPos(width, height, pos.left, pos.top); 
  •                             } 
  •                             bodyObj.css('cursor','se-resize'); 
  •                         } 
  •                     }); 
  •                 } 
  •             }, 
  •             'mouseup':function(e){ 
  •                 documentObj.unbind('mousemove'); 
  •                 bodyObj.css('cursor','default'); 
  •             } 
  •         }); 
  •          
  •         //get border position 
  •         function setBDPos(w,h,l,t){ 
  •             BD_E.css({'width':BD_WIDTH,'height':h,'left':l+w,'top':t}); 
  •             BD_S.css({'width':w,'height':BD_WIDTH,'top':t+h,'left':l}); 
  •             BD_SE.css({'left':l+w-BD_SE.width(),'top':t+h-BD_SE.height()}); 
  •         }; 
  •         //justify target is border ? 
  •         function isBD(target){       
  •             if(target && target.className){ 
  •                 return target.className.indexOf('ui-resizable-bd') != -1; 
  •             }    
  •             return false; 
  •         } 
  •     }; 
  • })(jQuery); 
  •  
  •  
  • $('#demo').resizable(); 
  •  
  •  
  •  
  •  


    网页题目:jquery调整大小(resizable)
    分享网址:http://kswsj.com/article/pijosj.html

    其他资讯

    

    Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号