suzzane2020 Posted March 30, 2007 Share Posted March 30, 2007 Hi, Iam working on drag and drop html control script. Here i have a list of html elements which can be dragged and dropped onto a dropable area. so far so good. But i need to position these elements when i drop them ie. I need to place them wherever i want in the dropable area. hw can i do tht using the div tag. Any help wud be appreciated Thank You Link to comment https://forums.phpfreaks.com/topic/44964-positioning-elements-using-div/ Share on other sites More sharing options...
micah1701 Posted March 30, 2007 Share Posted March 30, 2007 here is what I would do but i'm just writting this free-hand so it may not work. you should be able to get the idea <style type="css/text"> #movableDiv{ position: absolute; /* original coordinates */ top: 50px; left: 50px } </style> <script type="javascript"> function moveDiv(){ //do some sort of onClick thing to figure out where your mouse is // and where you want the top, left corner of the div to be var newTop = 600; var newLeft = 69; document.getElementById('movableDiv').style.top = newTop + "px"; document.getElementById('movableDiv').style.left = newLeft + "px"; } </script> <div id="movableDiv"> stuff inside div </div> Link to comment https://forums.phpfreaks.com/topic/44964-positioning-elements-using-div/#findComment-218334 Share on other sites More sharing options...
suzzane2020 Posted March 30, 2007 Author Share Posted March 30, 2007 hi, Thanx n yes i got an idea . Struggled a bit but got it to work. Link to comment https://forums.phpfreaks.com/topic/44964-positioning-elements-using-div/#findComment-218382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.