doujiao4710 2015-01-12 23:38
浏览 47
已采纳

使用twitter引导程序布局动态列插入

I am trying to show elements in a responsive structure based in 4 columns like this:

+------------------------ row ------------------------+

[--col-*-3--] [--col-*-3--] [--col-*-3--] [--col-*-3--]

+------------------------ row ------------------------+

[--col-*-3--] [--col-*-3--] [--col-*-3--] [--col-*-3--]

So I proceed to iterate the items:

<div class="row">
    <?php foreach ($items as $i): ?>
        <div class="col-lg-3">
            <?php echo $i->getName(); ?>
        </div>
    <?php endforeach; ?>
</div>

The code above will work for 4 items or less because twitter bootstrap grid systems (I think so) is based on 12 cols per row. I want to avoid this:

+------------------------ row ------------------------+

[--col-*-3--] [--col-*-3--] [--col-*-3--] [--col-*-3--] 
[--col-*-3--] ...

+------------------------ row ------------------------+

[--col-*-3--] [--col-*-3--] [--col-*-3--] [--col-*-3--] 

So, some people could say "chunk the array or use a flag to track if row is fill". But I want to avoid these operations in the html file. My question is, how can I deal with this design keeping four columns structure without broke responsive layout? Thank you in advance

  • 写回答

1条回答 默认 最新

  • duanke6249 2015-01-13 00:01
    关注

    I don't think that this will break your layout. Your solution should work, i've tried something similar. Maybe it's the .col-lg that breaks your solution for the smaller screen? Here an example with .col-xs. Do you try to specify the width of the col for every screen resolution?

     ...
    <div class="col-lg-3 col-md-3 col-xs-3"> 
     ...
    </div>
     ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大