Open In App

Tailwind CSS Grid Template Columns

This class accepts more than one value in tailwind CSS all the properties are covered as in class form. It is the alternative of CSS grid-template-columns property in CSS. It is used to set the number of columns and size of the columns of the grid, here we will do the same but for fast development of front-end. The number of columns is set by the number of values given to this class. 

Grid Template Columns:



Syntax:

<element class="grid grid-cols-number"> Contents... </element>

Example:






<!DOCTYPE html> 
<html>
  
<head
    <title>Tailwind grid-cols Class</title
  
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
          rel="stylesheet"
</head
  
<body class="text-center"
    <h1 class="text-green-600 text-5xl font-bold">
        GeeksforGeeks
    </h1
  
    <b>Tailwind CSS grid-cols Class</b
  
    <div id="main" class="grid grid-cols-3 gap-1 justify-evenly"
        <div class="bg-green-700 w-26 h-12">1</div
        <div class="bg-green-500 w-26 h-12">2</div
        <div class="bg-green-300 w-26 h-12">3</div
        <div class="bg-green-700 w-26 h-12">4</div
        <div class="bg-green-500 w-26 h-12">5</div
        <div class="bg-green-300 w-26 h-12">6</div
    </div
</body
  
</html>

Output:


Article Tags :