I am trying to put 3 divs (lets call them div1, div2 and div3) into one container div with 700px width. What I want to manage is that the content of the div1 is higher in the source code, but is visible lower at the webpage (please see attached picture).
<div id="container">
<div id="div1">content of the div1</div>
<div id="div2">content of the div2</div>
<div id="div3">content of the div3</div>
</div>
The problem I am not able to solve is, that all 3 divs may have varibale height. So I cannot use position:absolute;top: x px; or padding-top: x px
Picture of requested layout: http://snapshot.own.cz/divs.png
EDIT:
solved using JS as suggested in comments (JS after load gets real height of div2 and sets top: value to div1)
$(document).ready(function() {
var newtop = $('#div2').height() ;
$('#div1').css("top",newtop);
});
<style>
#container{
width: 700px;
clear: both;
}
#div1{
width: 700px;
background: red;
float: right;
position:relative;
top:20px;
}
#div2{
width: 500px;
height: 200px;
background: blue;
float: left;
position: absolute;
}
#div3{
width: 200px;
background: green;
float: left;
position:absolute;
left: 500px;
}
</style>
<div id="container">
<div id="div1">content of the div1</div>
<div id="div2">content of the div2</div>
<div id="div3">content of the div3</div>
</div>