I have a list of articles which have to be presented on two columns.
Everything is ok except that the height of articles could be very different and the result is that i can have a column a lot more longer that the other one.
It’s not a big issue but the result is not clean. You can see the picture attached to see.
It’s because, before i make a loop, i count all the articles and divide the result by 2 :
This is the code (a little bit more complicated in my template but it’s just html stuff)
// make a query to get the number of articles
$count_articles = 20;
$i = 0;
if ($i == 0) {
echo '<div class="column_1">';
}
if ($i <= 10) {
echo '<div style="float:left;width:350px;">';
echo $articles
echo '</div><div style="clear:both;"></div>';
$i++;
}
if ($i == 11) {
//close column_1, open column_2
echo '</div><div class="column_2">';
}
if ($i >= 11 && $i <= 20) {
echo '<div style="float:right;width:358px">';
echo $articles
echo '</div>';
if ($i ==20) {
//close column_2
echo '</div>';
}
$i++;
}
Do you know a way to get the height of articles before i make the loop or an other way to do that (with javascript maybe) ?