使用Laravel和foreach创建引导程序列

时间:2018-07-17 14:33:17

标签: laravel twitter-bootstrap laravel-5 bootstrap-4

我希望将我的$ favs对象的项目分组为每行4列

<div class="row row justify-content-center">
                          <div class="col-9">
                              <div class="row">
                                 @foreach ($favs->items as $fav)
                                  <ul class="col-sm-3 list-unstyled">
                                    <li class="subcat-li"><a href="{{ route('web.custom_url',$fav->seo->slug ) }}">{{ $fav->name }}</a></li>
                                  </ul>
                                 @endforeach
                              </div>
                          </div>
                        </div>

我希望它看起来像这样: enter image description here

1 个答案:

答案 0 :(得分:0)

   <div class="row">
        @foreach($favs->items as $fav)
        <div class="col-md-3">
            <a href="{{ route('web.custom_url',$fav->seo->slug ) }}">{{ $fav->name }}</a>
        </div>
        @endforeach
    </div>