【问题标题】:Build dynamic grid using jquery mobile and modulus使用 jquery mobile 和模数构建动态网格
【发布时间】:2013-02-27 11:08:10
【问题描述】:

我正在尝试使用 php 和 jquery mobile 构建动态网格。我想知道是否有人可以帮助我使用模数来确定 ui-block- 是否需要 a-d 取决于迭代的键值。

  <div class="ui-grid-c">
        @forelse($photos as $key=>$photo)

            @if($key == 1)
                <div class="ui-block-a">                                
                    <img src="{{ $photo['file'] }}" width="60" />
                </div>
            @elseif($key == 2)
                <div class="ui-block-b">                                
                    <img src="{{ $photo['file'] }}" width="60" />
                </div>
            @elseif($key == 3)
                <div class="ui-block-c">                                
                    <img src="{{ $photo['file'] }}" width="60" />
                </div>
            @elseif($key == 4)
                <div class="ui-block-d">                                
                    <img src="{{ $photo['file'] }}" width="60" />
                </div>  
            @endif

        @empty

            Nothing Found

        @endforelse
    </div>

我尝试了几种不同的模数变化,但都没有奏效。任何帮助将不胜感激。

【问题讨论】:

    标签: php jquery mobile blade


    【解决方案1】:

    您需要根据列数将您的 ui-grid-c 类修改为动态的。

    • ui-grid-a = 2 列
    • ui-grid-b = 3 列
    • ui-grid-c = 4 列

    为您的专栏..

    • ui-block-a - 是您的第一列
    • ui-block-b - 是你的第二列

    所以你需要记录你在列中添加的次数,然后添加字母。

    Using 会给你一个字符 a,然后在你添加列时为其他字符增加 86。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-30
      • 2011-12-08
      • 2012-02-16
      • 2013-07-16
      • 2012-05-31
      • 1970-01-01
      • 2011-08-30
      • 1970-01-01
      相关资源
      最近更新 更多