Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

How to to get one DIV to the front in case of cascaded DIVs

I have 4 DIVs if type  draggable and resizable as per the code below, I want when I select a div to move it or resize it to get it to the front and send the rest to the back, how can I do so?

 <style>
        #window1 { background-position: top left; width: 150px; height: 150px; padding: 0.5em; }
        #window2 { background-position: top left; width: 150px; height: 150px; padding: 0.5em; }
        #window3 { background-position: top left; width: 150px; height: 150px; padding: 0.5em; }
        #window4 { background-position: top left; width: 150px; height: 150px; padding: 0.5em; }
        .ui-resizable-helper { border: 2px dotted #00F; }
        </style>
        <script>
        $(function() {
                $( "#window1" ).draggable({containment: "#main"},{ cursor: "move", cursorAt: { top: 56, left: 56 } });
                $( "#window1" ).resizable({animate: true},{helper: "ui-resizable-helper"});
                $( "#window2" ).draggable({containment: "#main"},{ cursor: "move", cursorAt: { top: 56, left: 56 } });
                $( "#window2" ).resizable({animate: true},{helper: "ui-resizable-helper"});
                $( "#window3" ).draggable({containment: "#main"},{ cursor: "move", cursorAt: { top: 56, left: 56 } });
                $( "#window3" ).resizable({animate: true},{helper: "ui-resizable-helper"});
                $( "#window4" ).draggable({containment: "#main"},{ cursor: "move", cursorAt: { top: 56, left: 56 } });
                $( "#window4" ).resizable({animate: true},{helper: "ui-resizable-helper"});
        });
        </script>
<div id="window1" class="ui-widget-content">
        <p id="window1content">Window's content is not set</p>
</div>
<div id="window2" class="ui-widget-content">
        <p id="window2content">Window's content is not set</p>
</div>
<div id="window3" class="ui-widget-content">
        <p id="window3content">Window's content is not set</p>
</div>
<div id="window4" class="ui-widget-content">
        <p id="window4content">Window's content is not set</p>
</div>

Open in new window

0
Ashraf Hassanein
Asked:
Ashraf Hassanein
  • 5
  • 4
1 Solution
 
scgstuffCommented:
Could you set the z-index of the div that has been dragged?  The z-index would allow it to sit on top of the other divs.
0
 
leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/x2uK4/

$(function() {
    var start = function() {
        $(this).insertAfter(".ui-widget-content:last");
    }
    $( ".ui-widget-content" )
        .draggable({containment: "#main"},{ cursor: "move", cursorAt: { top: 56, left: 56 }, start:start })
        .resizable({animate: true},{helper: "ui-resizable-helper"});
});

Open in new window

0
 
Ashraf HassaneinAuthor Commented:
How can define the z axis?

Hi Leakim971, the code did not work, when I mouse click on a certain div it moves instead another one far of it.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
leakim971PluritechnicianCommented:
Which browser? Work fine for me on the latest Chrome, FF and IE10 & comp. mode

http://fiddle.jshell.net/x2uK4/show/
0
 
Ashraf HassaneinAuthor Commented:
Hi leakim971, that is reallly strange, I tested in chrome and the IE11 and I have the sane issue I copied the same same as your last file but it is as is, you can check in my url:

     https://www.hassans.nl/new
0
 
leakim971PluritechnicianCommented:
you did not notice my css update, I replaced your css ;-)
position must be absolute
0
 
Ashraf HassaneinAuthor Commented:
Now it is working :-) , I have a small problem, in your example you can freely move the div's up and down right and left without increasing its area, in mine I can only move it right and left if I want to move up and down I need to change its size, can you tell me what am I doing wrong?
0
 
leakim971PluritechnicianCommented:
add this css :

#main {
 height:100%;
}

Hi Leakim971, the code did not work, when I mouse click on a certain div it moves instead another one far of it.
for the next time, please, when you say it don't work, specify if come from the original answer OR from your deployment.
0
 
Ashraf HassaneinAuthor Commented:
Hi Leakim971, thanks  for your help, it now it is working my deployment, for the confusion.
0
 
Ashraf HassaneinAuthor Commented:
Very helpful solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now