In Tailwind CSS, row span makes an element occupy two or more rows within the grid. It is used to define the number of rows an element should occupy/span. It permits users to adjust the grid itemβs size and position across multiple rows and create different layouts. Moreover, it can be used to create flexible and responsive grid layouts for web pages.
This write-up will exemplify the method to make a rows span in Tailwind CSS.
How to Make a Rows Span in Tailwind?
To make the rows span in Tailwind, make an HTML program. Then, utilize the βrow-span-<value>β utility and define the number of rows to span. It is required to define the number of rows each specific element should span. Lastly, view the changes on the HTML web page for verification.
For practical implementation, check out the provided steps:
Step 1: Make Column Span in HTML Program
Create an HTML program and use the βrow-span-<value>β utilities with the grid items to make a column span. For instance, we have used the βrow-span-3β, βrow-span-2β and βrow-span-4β utilities as below:
<div class="grid grid-rows-4 grid-flow-col gap-3 m-3 text-center">
<div class="row-span-3 bg-teal-500 p-5">1</div>
<div class="bg-teal-500 p-5">2</div>
<div class="row-span-2 bg-teal-500 p-5">3</div>
<div class="bg-teal-500 p-5">4</div>
<div class="bg-teal-500 p-5">5</div>
<div class="row-span-4 bg-teal-500 p-5">6</div>
</div>
</body>
Here, in the parent <div> element:
- βgridβ class is utilized to create a grid layout.
- βgrid-row-4β class sets the rows number in the grid to 4.
- βgrid-flow-colβ class places the grid items horizontally in columns.
- βgap-3β class sets a spacing of 3 units between each grid item.
- βm-3β class applies a margin of 3 units around the grid container.
- βtext-centerβ class sets the text of each grid item to the center.
In the child <div> elements:
- βrow-span-3β class specifies that the element should span across 3 rows in the grid.
- βrow-span-2β class indicates that the element should span across 2 rows in the grid.
- βrow-span-4β class specifies that the element should span across 4 rows in the grid.
- βbg-teal-500β class sets the teal color to the background of the grid item.
- βp-5β class adds a padding of 5 units to the content inside the child <div> items.
Step 2: Verify Output
View the HTML web page to verify whether the row span has been applied or not:
In the above output, it can be observed that the row span has been applied successfully according to which it was specified.
Conclusion
To make the rows span in Tailwind, use the βrow-span-<value>β utility in the HTML program and specify the number of rows each element should span. For verification, view the changes on the HTML web page. This write-up has exemplified the method to make a rows span in Tailwind CSS.