Quick Guide To Grid Column Start & End

Let’s delve into the concept of Grid column start and end with examples in Tailwind Css through this article.

One critical aspect of the grid system is the ability to control the position and size of grid items within a grid container.

Grid Column Start and end

This is achieved using grid column start/end which allows you to specify where a grid item starts and ends in terms of grid columns.

It is an alternative to CSS grid-columns property.

Note: if the {start} and {end} values are the same, you can use the shorthand class col-{breakpoint}-{start} to define the starting position of the grid item.
Similarly, if the {end} value is not specified, the item will occupy all the remaining columns to the right of the starting position.


Grid Column Start & End Classes

ClassesOverview
col-autoThis utility class can be used to set the width of a grid column to be based on the content inside it.
col-span-1In a grid container, this sets the number of columns an element spans to 1.
col-span-2An element occupies two columns within a grid container using this class.
col-span-3Three columns are occupied by a grid item using this class.
col-span-4The grid item using this class covers four columns.
col-span-5The grid item stretches to occupy five column space.
col-span-6Six column space is utilized by the grid item.
col-span-7Using this class, the grid item covers the space of seven columns.
col-span-8An element in a grid container spreads on eight column space using this class.
col-span-9Nine columns are occupied by the grid item using this class.
col-span-10This class is used to make a grid item span to ten columns.
col-span-11In this case, the width of a grid column spans 11 grid tracks.
col-span-12Twelve columns are occupied by an element in a grid container.
col-span-fullThis class is used to specify that an element should span across all columns in a grid container.
col-start-1This class is used to start a grid item in the first column of the grid.
col-start-2Starts a grid item from the second column in the grid.
col-start-3Using this class, the grid item begins from the third column.
col-start-4The grid item starts from the fourth column.
col-start-5An element in a grid container using this class, starts from the fifth column of the grid.
col-start-6In this case, the grid item starts from the sixth column.
col-start-7This class is used to start a grid item from the seventh column.
col-start-8Using this class, the grid item starts from the eighth column.
col-start-9The grid item using this class starts from the ninth column of the grid.
col-start-10This class is used to set the starting column of an element to the 10th grid column in a grid container.
col-start-11The starting column position for an element within a grid container is specified as the 11th column line.
col-start-12In this case, the starting position of an element within a grid is defined as the 12th vertical grid line.
col-start-13Using this class, the grid item starting position is the 13th vertical grid line.
col-start-autoThis class is used when you want the grid item to start at the first available column in the grid.
col-end-1The end position of an element in a grid is specified as the first column line.
col-end-2A grid element’s second column line specifies its end position.
col-end-3An element’s end position is specified by the third column line in a grid.
col-end-4Fourth column lines indicate the end position of an element in a grid.
col-end-5An element in a grid is specified as having the fifth column line as its end position.
col-end-6This class sets the ending column of an element to be the 6th column in a grid.
col-end-7The ending column of an element in a grid is set to the 7th column using this class.
col-end-8In a grid, this class sets the ending column of the grid item as the 8th column.
col-end-9The closing column of a grid item will be set to the 9th column when using this class.
col-end-10It sets an item’s ending column as the 10th column in a grid.
col-end-11Using this class, the 11th column of a grid item is set as the ending column.
col-end-12In this case, the ending position of an element within a grid is defined as the 12th vertical grid line.
col-end-13When using this class, the grid item ending position is the 13th vertical grid line.
col-end-autoUsing this class, the end position of an element is defined as the last column of the grid container.

Spanning Columns (col-span)

This utility sets the number of columns an element should occupy in a grid container.

The number represents the amount of columns a grid column will occupy.

Syntax

<element class="col-span-number"> </element>

In the following example the col-span utility is being demonstrated:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="text-center"> <h1 class="text-gray-600 text-2xl font-semibold"> MrExamples </h1> <p class="font-medium my-2">Using col-span class in Tailwind</p> <p class="font-medium text-gray-500 text-sm">Total 5 rows in this grid</p> <div id="main" class="m-8 grid grid-cols-5 gap-1 justify-evenly font-medium"> <div class="bg-gray-300 col-span-1 rounded-lg h-12 ">col-span-1</div> <div class="bg-gray-300 col-span-4 rounded-lg h-12">col-span-4</div> <div class="bg-gray-300 col-span-1 rounded-lg h-12">col-span-1</div> <div class="bg-gray-400 col-span-2 rounded-lg h-12">col-span-2</div> <div class="bg-gray-300 col-span-3 rounded-lg h-12">col-span-3</div> <div class="bg-gray-400 col-span-5 rounded-lg h-12">col-span-5</div> </div> </body> </html>

Starting and ending lines (col-start|end)

This utility allows you to specify where a grid item starts and ends in terms of grid columns. The col-span utility can be used as well.

Syntax

<element class="col-start-number"> </element>

or

<element class="col-end-number"> </element>
This example makes use of the col-start, col-end and col-span classes implemented together:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="text-center"> <h1 class="text-gray-600 text-2xl font-semibold"> MrExamples </h1> <p class="font-medium my-2">Using col-span class in Tailwind</p> <p class="font-medium text-gray-500 text-sm">Total 5 rows in this grid</p> <div id="main" class="m-8 grid grid-cols-5 gap-1 justify-evenly font-medium"> <div class="bg-gray-300 col-start-1 col-span-1 col-end-3 rounded-lg h-12 ">col-start-1 col-span-1</div> <div class="bg-gray-300 col-start-3 col-end-5 rounded-lg h-12">col-start-3 col-end-5</div> <div class="bg-gray-300 col-start-2 col-span-2 col-end-4 rounded-lg h-12">col-start-2 col-span-2 col-end-4</div> <div class="bg-gray-300 col-start-4 col-end-5 rounded-lg h-12">col-start-4 col-end-5</div> <div class="bg-gray-300 col-start-1 col-span-3 rounded-lg h-12">col-start-1 col-span-3</div> <div class="bg-gray-300 col-start-2 col-span-4 rounded-lg h-12">col-start-2 col-span-4</div> </div> </body> </html>
We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *