Twitter bootstrap 使用Bootstrap和Laravel创建包含两个项目的动态旋转木马
我正在使用Bootstrap和Laravel创建一个旋转木马,每张幻灯片上有两个项目。然而,我似乎很难让它正确显示。我的代码有什么问题Twitter bootstrap 使用Bootstrap和Laravel创建包含两个项目的动态旋转木马,twitter-bootstrap,laravel,Twitter Bootstrap,Laravel,我正在使用Bootstrap和Laravel创建一个旋转木马,每张幻灯片上有两个项目。然而,我似乎很难让它正确显示。我的代码有什么问题 @if(!empty($products)) <div class="product-details"> <div class="carousel slide" id="productCarousel"> <div class="carousel-inner">
@if(!empty($products))
<div class="product-details">
<div class="carousel slide" id="productCarousel">
<div class="carousel-inner">
@foreach($products as $index => $product)
@if($index == 0 || (($index%2)-1 == 0))
<div class="item {{ $index == 1 ? 'active' : '' }}">
<div class="container">
<div class="row">
@endif
<div class="col-sm-6">
<p>This is an item</p>
</div>
@if($index == count($products) || ($index%2 == 0))
</div>
</div>
</div>
@endif
@endforeach
<a data-slide="prev" href="#find-a-forklift" class="left carousel-control"><i class="tk icon-chevron-left"></i></a>
<a data-slide="next" href="#find-a-forklift" class="right carousel-control"><i class="tk icon-chevron-right"></i></a>
</div>
</div>
</div>
@endif
@if(!empty($products))
@foreach($products作为$index=>$product)
@如果($index==0 | |)($index%2)-1==0))
@恩迪夫
这是一个项目
@如果($index==count($products)| |($index%2==0))
@恩迪夫
@endforeach
@恩迪夫
首先,我建议您使用Laravel Collection的方法稍微清理一下代码在这种情况下,您建议我怎么做?@Cavefish据我所知,您正在尝试使用旋转木马中的项目,因此我的建议是,您的代码逻辑太复杂,可能不必要,您可以使用chunk方法限制代码