I'm trying to get my head around a floating problem.
I get pairs of elements with 50% with, one of them is always higher than the other. With every new pair of elements the higher element changes sides (e.g first pair high element on the left, second pair high element on the right).
I need to get them in a pattern that looks like this (link):
Here is what I got:
.main {
width: 500px;
}
.container {
width: 100%;
}
.box50 {
width: 50%;
border: 1px solid black;
float: left;
box-sizing: border-box;
}
.high {
height: 120px;
}
.low {
height: 50px;
}
<div class="main">
<div class="container">
<div class="box50 left high">
<p>1</p>
</div>
<div class="box50 right low">
<p>2</p>
</div>
</div>
<div class="container">
<div class="box50 left low">
<p>3</p>
</div>
<div class="box50 right high">
<p>4</p>
</div>
</div>
</div>
By clearing the second row i get the div
to be in the correct order but i cant get the higher element to reach in the empty space above.
Is there a css solution for this?