div高度使用PHP

时间:2015-02-09 19:23:49

标签: php algorithm

我有一个div我需要找到它的高度。它包含一个准图像库。每行有5个图像,并且对于每行的开头,高度需要增加100px。我目前正在这样做:

<?php $counter = count(dirFilesAsArray(realpath($flexslider_gallery_path))); // get the number of files in the directory $height_per_row = '100'; // 100 px works per 5 images $images_per_row = '5'; $height = $counter <= $images_per_row ? $height_per_row : floor(($counter)/$images_per_row)*$height_per_row; ?>

这很好,但是代码自然会使得当第十个图像被击中时,高度从200px变为300px。虽然行已完成,但在添加第11个图像(或启动新行)之前,它不应增加到300px。我尝试了许多不同的事情,没有取得好成绩,我认为答案可能相当明显,我只是忽略它。那么也许你们其中一个人有答案?

Current functionality, notice we have 300px even though the next row hasnt started

0 个答案:

没有答案