列崩溃

时间:2016-12-25 22:46:22

标签: css zurb-foundation

使用基础zurb网格时,一些随机列会崩溃,为什么?

<div class="small-centered">
    <div class="row small-12 small-centered">   
      <?php foreach ($videos as $video): ?>
          <div class="column small-6 medium-4 large-4">
              <div>short text</div>
              <img src="https://placehold.it/150x150" />
          </div>
      <?php endforeach; ?>
    </div>
</div>

enter image description here 空白区域不是空div。

编辑:这是html和css输出 enter image description here

1 个答案:

答案 0 :(得分:1)

编辑:

您需要在最后一个元素中添加.end。使用计数器并像这样修改foreach循环(您可能需要稍微调整一下:

<?php 
$i = 0;
$len = count($videos);
foreach ($videos as $video): 
    if ($i == $len - 1) { 
        echo '<div class="column large-4 end">'; //this is the last
    } else { 
        echo '<div class="column large-4">'; // if not last-echo normally...
    } ?>
                  <div>short text</div>
                  <img src="https://placehold.it/150x150" />
              </div>
    <?php $i++;
endforeach; ?>