Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <title>Tailwind CSS Grid Example</title> <script src="https://cdn.tailwindcss.com"></script> <body class="bg-gray-100 p-4 sm:p-8"> <div class="max-w-4xl mx-auto space-y-12"> <!-- 1. Simple 3-column grid --> <div> <h3 class="text-lg font-semibold mb-4 text-gray-700">1. Basic 3-Column Grid</h3> <div class="grid grid-cols-3 gap-4"> <div class="h-20 bg-indigo-500 rounded flex items-center justify-center text-white">01</div> <div class="h-20 bg-indigo-500 rounded flex items-center justify-center text-white">02</div> <div class="h-20 bg-indigo-500 rounded flex items-center justify-center text-white">03</div> <div class="h-20 bg-indigo-500 rounded flex items-center justify-center text-white">04</div> <div class="h-20 bg-indigo-500 rounded flex items-center justify-center text-white">05</div> <div class="h-20 bg-indigo-500 rounded flex items-center justify-center text-white">06</div> </div> </div> <!-- 2. Spanning columns --> <div> <h3 class="text-lg font-semibold mb-4 text-gray-700">2. Spanning Columns</h3> <div class="grid grid-cols-3 gap-4"> <div class="col-span-2 h-20 bg-sky-500 rounded flex items-center justify-center text-white">col-span-2</div> <div class="h-20 bg-sky-500 rounded flex items-center justify-center text-white">02</div> <div class="h-20 bg-sky-500 rounded flex items-center justify-center text-white">03</div> <div class="col-span-2 h-20 bg-sky-500 rounded flex items-center justify-center text-white">col-span-2</div> </div> </div> <!-- 3. Responsive Grid --> <div> <h3 class="text-lg font-semibold mb-4 text-gray-700">3. Responsive Layout (1 col -> 2 -> 4)</h3> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4"> <div class="p-6 bg-white rounded-xl shadow-sm border border-gray-100"> <h4 class="font-bold">Card 1</h4> <p class="text-gray-500 text-sm mt-2">Stacks on mobile, spreads out on larger screens.</p> </div> <div class="p-6 bg-white rounded-xl shadow-sm border border-gray-100"> <h4 class="font-bold">Card 2</h4> <p class="text-gray-500 text-sm mt-2">Stacks on mobile, spreads out on larger screens.</p> </div> <div class="p-6 bg-white rounded-xl shadow-sm border border-gray-100"> <h4 class="font-bold">Card 3</h4> <p class="text-gray-500 text-sm mt-2">Stacks on mobile, spreads out on larger screens.</p> </div> <div class="p-6 bg-white rounded-xl shadow-sm border border-gray-100"> <h4 class="font-bold">Card 4</h4> <p class="text-gray-500 text-sm mt-2">Stacks on mobile, spreads out on larger screens.</p> </div> </div> </div> </div> </body>