我正在使用 Laravel/PHP/Tailwindcss 创建一个博客。我使用 tailwind 将博客页面设计为有 6 张博客卡片。使用时@foreach $posts as $post结果重复 6 次。我只希望博客卡片填充数据库中有多少篇文章而不是重复自己。就我而言,现在是 6。希望这张图片可以帮助提供更多我试图解释的内容。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 关注
- 94 浏览
添加回答
举报
0/150
提交
取消