Laravel, html, css: cara menampilkan data horizontal (tidak pakai table)

Sekarang hasilnya begini
q
w
e
r
t
y
u
i

Maunya kaya gini
q w e
r t y
u i

@foreach ($kategori as $k)
    <div class="row justify-content-center">
        <div class="col-lg-4">
            <p id="link">
                <a class="text-dark me-2" href="#{{ $k->slug }}">
                    <code class="text-danger"><i class="fa-solid fa-chevron-down opacity-70"></i></code><span>&nbsp;{{ $k->kategori }}</span>
                </a>
            </p>
        </div>
    </div>
@endforeach

avatar taraniskai13

@taraniskai13

9 Kontribusi 11 Poin


Jawaban Terpilih

Sudah ketemu gan, pakai method chunk.
https://laravel.com/docs/9.x/collections#method-chunk

@foreach ($kategori->chunk(3) as $chunk)
    <div class="row justify-content-center">
        @foreach ($chunk as $k)
        <div class="col-lg-4">
            <p id="link">
                <a class="text-dark me-2" href="#{{ $k->slug }}">
                    <code class="text-danger"><i class="fa-solid fa-chevron-down opacity-70"></i></code><span>&nbsp;{{ $k->kategori }}</span>
                </a>
            </p>
        </div>
    @endforeach
    </div>
@endforeach
avatar taraniskai13

@taraniskai13

9 Kontribusi 11 Poin

Jawaban

Sudah ketemu gan, pakai method chunk.
https://laravel.com/docs/9.x/collections#method-chunk

@foreach ($kategori->chunk(3) as $chunk)
    <div class="row justify-content-center">
        @foreach ($chunk as $k)
        <div class="col-lg-4">
            <p id="link">
                <a class="text-dark me-2" href="#{{ $k->slug }}">
                    <code class="text-danger"><i class="fa-solid fa-chevron-down opacity-70"></i></code><span>&nbsp;{{ $k->kategori }}</span>
                </a>
            </p>
        </div>
    @endforeach
    </div>
@endforeach
avatar taraniskai13

@taraniskai13

9 Kontribusi 11 Poin


Login untuk gabung berdiskusi