This can be solved easily if the divs have fixed height, say 20px. Then you can do the following trick:
<div>
<div style="width:200px;background:#F00;height:20px;margin-top:20px;"></div>
<div style="width:200px; background:#CCC;height:20px;margin-top:-40px;"></div>
</div>
What I did here is that added the margin-top to the below div in negative value. Not to mention that you must be good in calculations.
You can also use translateX and translateY CSS3 properties when the height is fixed and known.
What if the height is unknown?
If the heights of the div elements are not fixed or unknown, then it can be solved using javascript. (No way using pure CSS).
Here is the code:
<script>
window.onload = function(){
changePosition();
}
function changePosition(){
var childOne = document.getElementById('childOne');
var childTwo = document.getElementById('childTwo');
// Getting the height of the elements
var heightOne = childOne.offsetHeight;
var heightTwo = childTwo.offsetHeight;
// Giving marginTop to the first div equal to the height of the second div
childOne.style.marginTop = heightTwo;
// Giving the combination height of the two div's in negative
// to the second div.
childTwo.style.marginTop = -(heightOne + heightTwo);
}
</script>
I hope this atleast gives you an idea about what to do when you have more than two div’s