<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Move Box Exercises</title> <styletype= "Text/css">#big{width:300px;Height:200px;position:Absolute;Top:200px; Left:300px;background:#ccc;}H1{width:200px;Height:50px;Line-height:50px;text-align:Center;background:Orange;margin:0 Auto;cursor:Move;} </style></Head><Body> <DivID= "Big"> <H1class= "Titl"></H1> </Div> <Scripttype= "Text/javascript"> //gets the element specified by the parent element that you want to get. functionGetClass (clsname,parent) {varoparent=Parent?document.getElementById (parent):d ocument; varoH1=Oparent.getelementsbyclassname (clsname) [0]; returnoH1; } window.onload=drag; //adds a hold event to H1. functiondrag () {varH1node=GetClass ("titl","Big"); H1node.onmousedown=Fndown; } //gets the position of the pointer through a function. functionFndown (Event) {event=Event||window.event; varOdiv=document.getElementById ("Big"), //the distance between the cursor and the panel when the cursor is pressed. DISX=Event.clientx-Odiv.offsetleft; Disy=Event.clienty-Odiv.offsettop; Document.onmousemove= function(Event) {event=Event||window.event; Fnmove (Event,disx,disy); } document.onmouseup= function() {Document.onmousemove= NULL; } } functionFnmove (e,posx,posy) {varOdiv=document.getElementById ("Big"), L=E.clientx-PosX, T=E.clienty-PosY, WINW=Document.documentElement.clientWidth||Document.body.clientWidth, Winh=Document.documentElement.clientHeight||Document.body.clientHeight, Maxw=WINW-Odiv.offsetwidth, Maxh=Winh-Odiv.offsetheight; if(L<0) {L=Ten; } Else if(L>Maxw) {L=Maxw; } if(t<0) {T=Ten; } Else if(t>maxh) {T=Maxh; } oDiv.style.left=L+"px"; ODiv.style.top=T+"px"; } </Script></Body></HTML>
About the specific implementation of the mobile Div (JS)