<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Dialog</title> <mce:style type="text/css"><!-- .dialogcontainter{height:400px; width:400px; border:1px solid #14495f; position:absolute; font-size:13px;} .dialogtitle{height:26px; width:auto; background-image:url('http://album.hi.csdn.net/app_uploads/wtcsy/20090603/103444839.p.gif');} .dialogtitleinfo{float:left;height:20px; margin-top:2px; margin-left:10px;line-height:20px; vertical-align:middle; color:#FFFFFF; font-weight:bold; } .dialogtitleico{float:right; height:20px; width:21px; margin-top:2px; margin-right:5px;text-align:center; line-height:20px; vertical-align:middle; background-image:url('http://album.hi.csdn.net/app_uploads/wtcsy/20090603/103419495.p.gif');background-position:-21px 0px} .dialogbody{ padding:10px; width:auto; background-color: #FFFFFF;} .dialogbottom{ bottom:1px; right:1px;cursor:nw-resize; position:absolute; background-image:url('http://album.hi.csdn.net/app_uploads/wtcsy/20090603/103419495.p.gif'); background-position:-42px -10px; width:10px; height:10px; font-size:0;} --></mce:style><style type="text/css" mce_bogus="1">.dialogcontainter{height:400px; width:400px; border:1px solid #14495f; position:absolute; font-size:13px;} .dialogtitle{height:26px; width:auto; background-image:url('http://album.hi.csdn.net/app_uploads/wtcsy/20090603/103444839.p.gif');} .dialogtitleinfo{float:left;height:20px; margin-top:2px; margin-left:10px;line-height:20px; vertical-align:middle; color:#FFFFFF; font-weight:bold; } .dialogtitleico{float:right; height:20px; width:21px; margin-top:2px; margin-right:5px;text-align:center; line-height:20px; vertical-align:middle; background-image:url('http://album.hi.csdn.net/app_uploads/wtcsy/20090603/103419495.p.gif');background-position:-21px 0px} .dialogbody{ padding:10px; width:auto; background-color: #FFFFFF;} .dialogbottom{ bottom:1px; right:1px;cursor:nw-resize; position:absolute; background-image:url('http://album.hi.csdn.net/app_uploads/wtcsy/20090603/103419495.p.gif'); background-position:-42px -10px; width:10px; height:10px; font-size:0;}</style> </head> <body > <input value="创建" type="button" onclick="creat()" /> <div id='aa'></div> <mce:script type="text/javascript"><!-- var z=1,i=1,left=10 var isIE = (document.all) ? true : false; var $ = function (id) { return document.getElementById(id); }; var Extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } } var Bind = function(object, fun,args) { return function() { return fun.apply(object,args||[]); } } var BindAsEventListener = function(object, fun) { var args = Array.prototype.slice.call(arguments).slice(2); return function(event) { return fun.apply(object, [event || window.event].concat(args)); } } var CurrentStyle = function(element){ return element.currentStyle || document.defaultView.getComputedStyle(element, null); } function create(elm,parent,fn){var element = document.createElement(elm);fn&&fn(element); parent&&parent.appendChild(element);return element}; function addListener(element,e,fn){ element.addEventListener?element.addEventListener(e,fn,false):element.attachEvent("on" + e,fn)}; function removeListener(element,e,fn){ element.removeEventListener?element.removeEventListener(e,fn,false):element.detachEvent("on" + e,fn)}; var Class = function(properties){ var _class = function(){return (arguments[0] !== null && this.initialize && typeof(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;}; _class.prototype = properties; return _class; }; var Dialog = new Class({ options:{ Width : 400, Height : 400, Left : 100, Top : 100, Titleheight : 26, Minwidth : 200, Minheight : 200, CancelIco : true, ResizeIco : false, Info : "新闻标题", Content : "无内容", Zindex : 2 }, initialize:function(options){ this._dragobj = null; this._resize = null; this._cancel = null; this._body = null; this._x = 0; this._y = 0; this._fM = BindAsEventListener(this, this.Move); this._fS = Bind(this, this.Stop); this._isdrag = null; this._Css = null; //////////////////////////////////////////////////////////////////////////////// this.Width = this.options.Width; this.Height = this.options.Height; this.Left = this.options.Left; this.Top = this.options.Top; this.CancelIco = this.options.CancelIco; this.Info = this.options.Info; this.Content = this.options.Content; this.Minwidth = this.options.Minwidth; this.Minheight = this.options.Minheight; this.Titleheight= this.options.Titleheight; this.Zindex = this.options.Zindex; Extend(this,options); Dialog.Zindex = this.Zindex //////////////////////////////////////////////////////////////////////////////// 构造dialog var obj = ['dialogcontainter','dialogtitle','dialogtitleinfo','dialogtitleico','dialogbody','dialogbottom']; for(var i = 0;i<obj.length;i++) { obj[i]=create('div',null,function(elm){elm.className = obj[i];}); } obj[2].innerHTML = this.Info; obj[4].innerHTML = this.Content; obj[1].appendChild(obj[2]); obj[1].appendChild(obj[3]); obj[0].appendChild(obj[1]); obj[0].appendChild(obj[4]); obj[0].appendChild(obj[5]); document.body.appendChild(obj[0]); this._dragobj = obj[0]; this._resize = obj[5]; this._cancel = obj[3]; this._body = obj[4]; ////////////////////////////////////////////////////////////////////////////////o,x1,x2 ////设置Dialog的长 宽 ,left ,top with(this._dragobj.style){ height = this.Height + "px";top = this.Top + "px";width = this.Width +"px";left = this.Left + "px";zIndex = this.Zindex; } this._body.style.height = this.Height - this.Titleheight-parseInt(CurrentStyle(this._body).paddingLeft)*2+'px'; /////////////////////////////////////////////////////////////////////////////// 添加事件 addListener(this._dragobj,'mousedown',BindAsEventListener(this, this.Start,true)); addListener(this._cancel,'mouseover',Bind(this,this.Changebg,[this._cancel,'0px 0px','-21px 0px'])); addListener(this._cancel,'mouseout',Bind(this,this.Changebg,[this._cancel,'0px 0px','-21px 0px'])); addListener(this._cancel,'mousedown',BindAsEventListener(this,this.Disappear)); addListener(this._body,'mousedown',BindAsEventListener(this, this.Cancelbubble)); addListener(this._resize,'mousedown',BindAsEventListener(this, this.Start,false)); }, Disappear:function(e){ this.Cancelbubble(e); document.body.removeChild(this._dragobj); }, Cancelbubble:function(e){ this._dragobj.style.zIndex = ++Dialog.Zindex; document.all?(e.cancelBubble=true):(e.stopPropagation()) }, Changebg:function(o,x1,x2){ o.style.backgroundPosition =(o.style.backgroundPosition==x1)?x2:x1; }, Start:function(e,isdrag){ if(!isdrag){this.Cancelbubble(e);} this._Css = isdrag?{x:"left",y:"top"}:{x:"width",y:"height"} this._dragobj.style.zIndex = ++Dialog.Zindex; this._isdrag = isdrag; this._x = isdrag?(e.clientX - this._dragobj.offsetLeft||0):(this._dragobj.offsetLeft||0) ; this._y = isdrag?(e.clientY - this._dragobj.offsetTop ||0):(this._dragobj.offsetTop||0); if(isIE) { addListener(this._dragobj, "losecapture", this._fS); this._dragobj.setCapture(); } else { e.preventDefault(); addListener(window, "blur", this._fS); } addListener(document,'mousemove',this._fM) addListener(document,'mouseup',this._fS) }, Move:function(e){ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); var i_x = e.clientX - this._x, i_y = e.clientY - this._y; this._dragobj.style[this._Css.x] = (this._isdrag?Math.max(i_x,0):Math.max(i_x,this.Minwidth))+'px'; this._dragobj.style[this._Css.y] = (this._isdrag?Math.max(i_y,0):Math.max(i_y,this.Minheight))+'px' if(!this._isdrag) this._body.style.height = Math.max(i_y -this.Titleheight,this.Minheight-this.Titleheight)-2*parseInt(CurrentStyle(this._body).paddingLeft)+'px'; }, Stop:function(){ removeListener(document,'mousemove',this._fM); removeListener(document,'mouseup',this._fS); if(isIE) { removeListener(this._dragobj, "losecapture", this._fS); this._dragobj.releaseCapture(); } else { removeListener(window, "blur", this._fS); }; } }) new Dialog({Width:300,Height:300,Left:300,Top:300}); new Dialog({Info:"人族",Content:"人族很强吗?"}); function creat(){ new Dialog({Info:title="标题"+i,Left:300+left,Top:300+left,Content:'内容'+i,Zindex:(++Dialog.Zindex)}); i++;left +=10; } // --></mce:script> </body> </html>
您还没有登录,请您登录后再发表评论
可拖动div边框改变大小的方法,jquery拖拽改变div大小效果,。。。。。。。。。。。。。。。。。。。。。。。。。
选中复选框(可移动、可调整大小)后,打开的DIV具有移动/调整大小的功能(此时移动/调整大小快捷键可使用); 反之,不可移动/调整大小(此时移动/调整大小快捷键无效) 单选框默认居中打开选中,无论有无保存DIV位置和...
拖拽并同时拖拽改变div大小暂无兼容性问题
dragresize 可让用户调整页面DIV的大小和位置 dragresize 可让用户调整页面DIV的大小和位置
Div拖动/调整大小实例 教你迅速的掌握如何写js 可以用鼠标控制div大小和位置 Div拖动/调整大小实例 教你迅速的掌握如何写js 可以用鼠标控制div大小和位置
手动拖动div改变窗口宽度大小 左中右三列拖拽
DIV层拖动的实现,可改变大小.DIV层拖动的实现,可改变大小.
js实现 1.两列的左右拖动改变div大小 2.三列的左右拖动改变div大小 3.两行的上下拖动改变div大小 可用于各种框架 vue React Angular
主要介绍了vue实现div可拖动位置也可改变盒子大小,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
纯js版本的拖动div 拉伸div 复用拖拽函数 复用改变大小函数
react-dnr - 采用React.js构建的可拖动和可调整大小的窗口
NULL 博文链接:https://yangqianyu222.iteye.com/blog/665834
js拖拽div随意摆放 js拖拽div随意摆放 js拖拽div随意摆放
JQ实现DIV大小、位置拖动调整源码,完美无措
里给大家分享的是一段自己编写的使用jQuery实现拽调整Div层大小的代码,非常实用,推荐给有需要的小伙伴们。
html5+css+jquery通过鼠标拖拽来移动对象位置、改变大小、和旋转的实现 代码简洁、易懂、易改造
可拖动和可调整大小的div
Vue可拖动的div 说明 vue可拖拽可伸缩的组件,目前只是上方,详见以下传送门 安装 npm install vue-draggable-div ... 可调整大小 descibe:是否可缩放 类型:布尔型 要求:假 默认值:true < vue-draggable-di
可拖拽的bootstrap弹出窗口结合jquery-ui实现的弹出和拖拽效果。
最近在使用vue的时候,遇到一个需求,实现左右div可通过中间部分拖拽调整宽度,类似于这样 这是我最终的实现效果 还是老话,因为我不是专业的前端工程师,只是兼职写一些简单的前端,所以这个功能的实现得益于以下...
相关推荐
可拖动div边框改变大小的方法,jquery拖拽改变div大小效果,。。。。。。。。。。。。。。。。。。。。。。。。。
选中复选框(可移动、可调整大小)后,打开的DIV具有移动/调整大小的功能(此时移动/调整大小快捷键可使用); 反之,不可移动/调整大小(此时移动/调整大小快捷键无效) 单选框默认居中打开选中,无论有无保存DIV位置和...
拖拽并同时拖拽改变div大小暂无兼容性问题
dragresize 可让用户调整页面DIV的大小和位置 dragresize 可让用户调整页面DIV的大小和位置
Div拖动/调整大小实例 教你迅速的掌握如何写js 可以用鼠标控制div大小和位置 Div拖动/调整大小实例 教你迅速的掌握如何写js 可以用鼠标控制div大小和位置
手动拖动div改变窗口宽度大小 左中右三列拖拽
DIV层拖动的实现,可改变大小.DIV层拖动的实现,可改变大小.
js实现 1.两列的左右拖动改变div大小 2.三列的左右拖动改变div大小 3.两行的上下拖动改变div大小 可用于各种框架 vue React Angular
主要介绍了vue实现div可拖动位置也可改变盒子大小,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
纯js版本的拖动div 拉伸div 复用拖拽函数 复用改变大小函数
react-dnr - 采用React.js构建的可拖动和可调整大小的窗口
NULL 博文链接:https://yangqianyu222.iteye.com/blog/665834
js拖拽div随意摆放 js拖拽div随意摆放 js拖拽div随意摆放
JQ实现DIV大小、位置拖动调整源码,完美无措
里给大家分享的是一段自己编写的使用jQuery实现拽调整Div层大小的代码,非常实用,推荐给有需要的小伙伴们。
html5+css+jquery通过鼠标拖拽来移动对象位置、改变大小、和旋转的实现 代码简洁、易懂、易改造
可拖动和可调整大小的div
Vue可拖动的div 说明 vue可拖拽可伸缩的组件,目前只是上方,详见以下传送门 安装 npm install vue-draggable-div ... 可调整大小 descibe:是否可缩放 类型:布尔型 要求:假 默认值:true < vue-draggable-di
可拖拽的bootstrap弹出窗口结合jquery-ui实现的弹出和拖拽效果。
最近在使用vue的时候,遇到一个需求,实现左右div可通过中间部分拖拽调整宽度,类似于这样 这是我最终的实现效果 还是老话,因为我不是专业的前端工程师,只是兼职写一些简单的前端,所以这个功能的实现得益于以下...