views:

50

answers:

2

I have a list of div pairs: MainDiv's and infPanel Divs. I need to put infPanel div's upon MainDiv and eliminate distance between MainDiv's. The best decision that I see is to set image in MainDiv with background option and just put infPanel inside MainDiv, but because of some technical requirements it is better to post image through just tag.

Another solution is to use position: absolute; and with JS set the position for each infPanel, but it will be great to eliminate JS.

Can you suggest more "agile" solution? Thank you.

alt text

A: 

If you just want the InfPanel at the bottom of MainDiv, you don't need JS at all, you can do it with CSS:

.MainPanel {
  position: relative;
}

.InfPanel {
  position: absolute;
  bottom: 0;
}
casablanca
The problem that there is a lot of such div groups (.
andrii
Is the height of these divs fixed?
casablanca
+1  A: 

You may use margin with negative values.

For example,

element{margin-top:-100px;}

will "move" the element 100 pixels to the top, overlapping other element.

Note that margin-top with negative values works also well with position:absolute; if you need to specify a z-index to reorder elements. It means that instead of specifying the top and left for each element, you will "move" the element to the top, according to its actual position (whereas top and left fix the position according to the page).

MainMa
The problem that the infPanel is appear under Main div and z-index doesn't help ((
andrii
@andrii: is it possible to reorder elements in HTML? It will be enough to put the elements in correct z-order. If you cannot do that, than see the edit to my answer.
MainMa
It really helps! Thank you!
andrii