我正在使用 Laravel/PHP/Tailwindcss 創(chuàng)建一個博客。我使用 tailwind 將博客頁面設(shè)計(jì)為有 6 張博客卡片。使用時@foreach $posts as $post結(jié)果重復(fù) 6 次。我只希望博客卡片填充數(shù)據(jù)庫中有多少篇文章而不是重復(fù)自己。就我而言,現(xiàn)在是 6。希望這張圖片可以幫助提供更多我試圖解釋的內(nèi)容。https://ibb.co/PYMMf3Zhttps://ibb.co/NLyFRCG (#2)索引.blade.php@extends('layout')@section('title', 'Blog')@section('content')@foreach ($posts as $post)<body class="text-cw-grey-700 "> <main class="container mx-auto max-w-6xl px-5"> <article class="border-t border-cw-grey-100 flex justify-between py-10"> <a href="#" class="w-1/2 mr-12"> <img src="images/T-Sky.jpg" alt="" class="border-sm"> </a> <div class="w-1/2 mt-4"> <a href="#" class="text-cw-blue-300 hover:text-cw-blue-600 hover:underline text-sm mb-1 block">Link</a> <h1 class="mb-3"><a href="#" class="font-bold font-work-sans text-3xl text-cw-gray-800 leading-tight hover:text-cw-blue-600 hover:underline">{{ $post->title }}</a> </h1> <p class="leading-relaxed">{{ $post->excerpt }}</p> </div> </article> <div class="mt-4 grid grid-cols-3 gap-8 row-gap-6"> <article> <a href="#"> <img src="images/T-Sky.jpg" alt="" class="mb-2"> </a> <a href="#" class="text-cw-blue-300 hover:text-cw-blue-600 hover:underline text-sm mb-1 block">Text here</a> <h2><a href="#" class="font-bold font-work-sans text-xl text-cw-gray-900 hover:text-cw-blue-600 hover:underline ">{{ $post->title }}</a> </h2> <p class="text-sm leading-loose">{{ $post->excerpt }}</p> </article> <article> <a href="#"> <img src="images/T-Sky.jpg" alt="" class="mb-2"> </a> <a href="#" class="text-cw-blue-300 hover:text-cw-blue-600 hover:underline text-sm mb-1 block">Text here</a> <h2><a href="#" class="font-bold font-work-sans text-xl text-cw-gray-900 hover:text-cw-blue-600 hover:underline ">{{ $post->title }}</a> </h2>
- 0 回答
- 0 關(guān)注
- 112 瀏覽
添加回答
舉報
0/150
提交
取消