5

I am looking at this fiddle: http://jsfiddle.net/kDs2Q/45/

Is there a way to layer the divs/line in a way so that the line will be behind the other divs? I want to be able to draw the line from the center of one div to the center of the other but not see the line cross over the actual boxes.

This is how I would to the center-to-center:

var off1 = getOffset(div1);
var off2 = getOffset(div2);
var x1 = off1.left + off1.width/2;
var y1 = off1.top + off1.height/2;
var x2 = off2.left + off1.width/2;
var y2 = off2.top + off1.height/2;
0

2 Answers 2

5

Yes use z-index in your style.

z-index:-1

JSFiddle http://jsfiddle.net/D24uC/

0
1

Use z-indexes, the DIVs need to have a higher z-index than the 'line-div'.

Give it a try, set the DIVs z-index to 1000 or something and see the result:

http://jsfiddle.net/kDs2Q/884/

<div id="div1" style="position:absolute; z-index:1000; background-color:blue; width:100px; height: 200px;top: 200px; left: 100px;">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.