我试图在laravel中制作可折叠面板。我不确定如何制作以下线动态
<div id="collapse1" class="panel-collapse collapse">
我试图通过以下方式做到这一点,但它不起作用
@foreach($cons as $con )
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1"><img alt="{{$con->image}}" src="{{URL::asset('albums/'.$con->image)}}" width="200" height="200"></a>
</h4>
</div>
<div id="collapse{{$con->id}}" class="panel-collapse collapse">
<div class="panel-body">{{$con->title}}</div>
<div class="panel-footer">{!!$con->details!!}</div>
</div>
</div>
</div>
@endforeach
答案 0 :(得分:2)
您错过了更改href
链接上的panel-heading
。
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<!-- Editing the HREF from original -->
<a data-toggle="collapse" href="#collapse{{$con->id}}"><img alt="{{$con->image}}" src="{{URL::asset('albums/'.$con->image)}}" width="200" height="200"></a>
</h4>
</div>
<div id="collapse{{$con->id}}" class="panel-collapse collapse">
<div class="panel-body">{{$con->title}}</div>
<div class="panel-footer">{!!$con->details!!}</div>
</div>
</div>
</div>
</div>