I have a list of divs with a variable height that which needs to be float'ed next to each other. The problem is the comment 4 should be placed above comment 2. But of course it can't do that because the comment 3 is taking its place.
Is this somehow doable in css with out changing the markup too much? The comments are added dynamically so its not always 5 comments. I made a jsfiddle showing the problem http://jsfiddle.net/Kv2Qf/ - What I have currently is this:
<div id="CommentsContainer">
<div class="Comment">
<div class="CommentContent" style="height: 250px;">
Comment 1
</div>
</div>
<div class="Comment">
<div class="CommentContent" style="height: 100px;">
Comment 2
</div>
</div>
<div class="Comment">
<div class="CommentContent" style="height: 200px;">
Comment 3
</div>
</div>
<div class="Comment">
<div class="CommentContent" style="height: 250px;">
Comment 4
</div>
</div>
</div>
With the styling:
#CommentsContainer
{
width: 783px;
height: 500px;
background-color: #f2f2f2;
}
.Comment
{
width: 229px;
float: left;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
margin-bottom: 10px;
margin-right: 10px;
border: 1px solid #aaaaaa;
background-color: #fffec7;
}
Result:
Expected Result: