Open In App

Tailwind CSS Gap

This class accepts more than one value in tailwind CSS all the properties are covered as in class form. It is the alternative to the CSS gap property. This class is used to set the spacing also caller gutter between the rows and columns. As like column-gap and row-gap using separately both so that one can use simply gap property that can given column as well as row gap.

Gap: There are total of 105 class for gap, x and y axis separately included also.



gap-number: By using only gap class without mentioning the axis will keep the in both axis according to the mentioned number:

Syntax:



<element class="gap-number"> Contents... </element>

Parameter: This class accept a single value as mentioned above and described below:

Example:




<!DOCTYPE html> 
<html>
  
<head
    <title>Tailwind gap 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 gap Class</b
  
    <div id="main" class="grid grid-rows-2
                          grid-flow-col gap-5"> 
        <div class="bg-green-500 rounded-lg m-4 h-12">1</div
        <div class="bg-green-500 rounded-lg m-4 h-12">2</div
        <div class="bg-green-500 rounded-lg m-4 h-12">3</div
        <div class="bg-green-500 rounded-lg m-4 h-12">4</div
        <div class="bg-green-500 rounded-lg m-4 h-12">5</div
        <div class="bg-green-500 rounded-lg m-4 h-12">6</div
    </div
</body
  
</html>

Output:

gap-x-number: By using the gap-x class will keep the gap in x-axis according to the mentioned number:

Syntax:

<element class="gap-x-number"> Contents... </element>

Example:




<!DOCTYPE html> 
<html>
  
<head
    <title>Tailwind gap-x-number 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 gap-x-number Class</b
  
    <div id="main" class="grid grid-rows-2
                          grid-flow-col gap-x-5"> 
        <div class="bg-green-500 rounded-lg m-4 h-12">1</div
        <div class="bg-green-500 rounded-lg m-4 h-12">2</div
        <div class="bg-green-500 rounded-lg m-4 h-12">3</div
        <div class="bg-green-500 rounded-lg m-4 h-12">4</div
        <div class="bg-green-500 rounded-lg m-4 h-12">5</div
        <div class="bg-green-500 rounded-lg m-4 h-12">6</div
    </div
</body
  
</html>

Output:

gap-y-number: By using the gap-y class will keep the gap in x-axis according to the mentioned number:

Syntax:

<element class="gap-y-number"> Contents... </element>

Example:




<!DOCTYPE html> 
<html>
  
<head
    <title>Tailwind gap-y-number 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 gap-y-number Class</b
  
    <div id="main" class="grid grid-rows-2
                          grid-flow-col gap-y-5"> 
        <div class="bg-green-500 rounded-lg m-4 h-12">1</div
        <div class="bg-green-500 rounded-lg m-4 h-12">2</div
        <div class="bg-green-500 rounded-lg m-4 h-12">3</div
        <div class="bg-green-500 rounded-lg m-4 h-12">4</div
        <div class="bg-green-500 rounded-lg m-4 h-12">5</div
        <div class="bg-green-500 rounded-lg m-4 h-12">6</div
    </div
</body
  
</html>

Output:


Article Tags :