tailwind css grid items width and height

You can use the `w-{width}` and `h-{height}` classes in Tailwind CSS to set the width and height of grid items. For example, if you want to set the width of an item to 1/3 of the container and the height to 100px, you can use the following classes:


```html

<div class="grid grid-cols-3">

 <div class="w-full h-100"></div>

 <div class="w-full h-100"></div>

 <div class="w-full h-100"></div>

</div>

```


Here, `grid-cols-3` sets the number of columns in the grid to 3. The `w-full` class sets the width of each item to 1/3 of the container, and the `h-100` class sets the height of each item to 100px.


I hope this helps! Let me know if you have any other questions.


Source: Conversation with Bing, 7/13/2023

(1) How to make grid items auto height using tailwind CSS - GeeksforGeeks. https://www.geeksforgeeks.org/how-to-make-grid-items-auto-height-using-tailwind-css/.

(2) Height and Width. Modern CSS with Tailwind - Medium. https://medium.com/pragmatic-programmers/height-and-width-53ab989bbb74.

(3) TailwindCSS Width and Height - Learn TailwindCSS - DevDojo. https://devdojo.com/guide/tailwindcss/width-height.

(4) Grid Template Columns - Tailwind CSS. https://tailwindcss.com/docs/grid-template-columns.

(5) Height - Tailwind CSS. https://tailwindcss.com/docs/height.

(6) How can I make CSS grid items have auto height using tailwind?. https://stackoverflow.com/questions/62346424/how-can-i-make-css-grid-items-have-auto-height-using-tailwind.

To view or add a comment, sign in

More articles by Deepak Prajapat

Explore content categories