@shyann
To create a responsive grid layout in Tailwind CSS, you can use the built-in grid system classes. Here's a simple example:
1 2 3 4 5 6 7 8 9 |
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4"> <div class="bg-gray-200 p-4">Item 1</div> <div class="bg-gray-200 p-4">Item 2</div> <div class="bg-gray-200 p-4">Item 3</div> <div class="bg-gray-200 p-4">Item 4</div> <div class="bg-gray-200 p-4">Item 5</div> <div class="bg-gray-200 p-4">Item 6</div> <div class="bg-gray-200 p-4">Item 7</div> </div> |
In this example, we have a grid container with different column sizes based on screen sizes:
You can also adjust the gap between grid items by using the gap-{size}
class. In this case, we used gap-4
to add a gap between items.
Tailwind CSS makes it easy to create responsive grid layouts by providing utility classes for different screen sizes. Customize the grid layout by adjusting the column sizes and gaps based on your design needs.