Tailwind CSS Display

It acknowledges more than one worth in tailwind CSS. Every one of the properties is shrouded as in class structure. It is an option in contrast to the CSS display property. This class is utilized to characterize how the parts (div, hyperlink, heading, and so on) will be put on the site page. As the name proposes, this property is utilized to characterize the display of the various pieces of a website page.

Display Classes

The display classes are listed as follows:

  • block: It is utilized to show a component as a block component (element).
  • inline-block: It is utilized to show an element as an inline-level block holder(container).
  • inline: It is utilized to show an element as an inline element.
  • flex: It is utilized to show an element as a block-level flex holder.
  • inline-flex: It is utilized to show an element as an inline-level flex holder.
  • table: It is utilized to set the conduct as <table> for all components.
  • table-caption: It is utilized to set the conduct as <caption> for all components.
  • table-cell: It is utilized to set the conduct as <td> for all components.
  • table-column: It is utilized to set the conduct as <col> for all components.
  • table-column-group: It is utilized to set the conduct as <column> for all components.
  • table-footer-group: It is utilized to set the conduct as <footer> for all components.
  • table-header-group: It is utilized to set the conduct as <header> for all components.
  • table-row-group: It is utilized to set the conduct as <row> for all components.
  • table-row: It is utilized to set the conduct as <tr> for all components.
  • flow-root: It is utilized to set the default value.
  • grid: It is utilized to show an element as a block-level grid container.
  • inline-grid: It is utilized to show a component as an inline-level grid container.
  • contents: It is utilized to vanish the container.
  • hidden: It is utilized to eliminate the element.
  • block: It is utilized to show an element as a block-level element. It is a default property of div. This class puts the div consistently in an upward direction. The height and width of the div can be changed utilizing the block class on the off chance that the width isn't referenced, then, at that point, the div under block class will take up the width of the container.

Syntax:

<element display="block">...</element>

Code Examples

Example 1:

Code is as follows:

<!DOCTYPE html> 
<head> 
<link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
rel="stylesheet"> 
</head> 
<body class="text-center"> 
<center>
<h1 class="text-red-600 text-5xl font-bold">
Tutorial and Example
</h1> 
<b> block Class - Tailwind CSS</b> 
<div class="bg-red-200 p-4 mx-16 space-y-4">
<span class="block h-12 bg-red-500 rounded-lg">1</span>
<span class="block h-12 bg-red-500 rounded-lg">2</span>
<span class="block h-12 bg-red-500 rounded-lg">3</span>
</div> 
</center>
</body> 
</html>

The output for the above code is:

Tailwind CSS Display

inline-block: It is utilized to show an element as an inline-level block container. This component utilizes the two properties referenced above, block and inline. Thus, this class adjusts the div inline yet the thing that matters is it can alter (edit) the height and the width of the block. Essentially, this will adjust the div both in the block and inline design (fashion).

Syntax:

<element display="inline-block">...</element>

Example 2:

Code is as follows:

<!DOCTYPE html> 
<head> 
<link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
rel="stylesheet"> 
</head> 
<body class="text-center"> 
<center>
<h1 class="text-red-600 text-5xl font-bold">
Tutorial and Example
</h1> 
<b>inline-block Class - Tailwind CSS </b> 
<div class="bg-red-200 p-4 mx-16 space-y-4">
<span class="inline-block w-32 h-12 bg-red-500 rounded-lg">1</span>
<span class="inline-block w-32 h-12 bg-red-500 rounded-lg">2</span>
<span class="inline-block w-32 h-12 bg-red-500 rounded-lg">3</span>
</div> 
</center>
</body> 
</html>

The output for the above code is:

Tailwind CSS Display

inline: It is utilized to show an element as an inline element. This class is the default property of anchor labels (tags). It is utilized to put the div inline in a level way (horizontal manner). The inline display property disregards the height and the width set by the client (user).

Syntax:

<element display="inline">...</element>

Example 3:

Code is as follows:

<!DOCTYPE html> 
<head> 
<link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
rel="stylesheet"> 
</head> 
<body class="text-center"> 
<center>
<h1 class="text-red-600 text-5xl font-bold">
Tutorial and Example
</h1> 
<b>inline Class - Tailwind CSS </b> 
<div class="bg-red-200 p-4 mx-16 space-y-4">
<span class="inline bg-red-500 rounded-lg">1</span>
<span class="inline bg-red-500 rounded-lg">2</span>
<span class="inline bg-red-500 rounded-lg">3</span>
</div> 
</center>
</body> 
</html>

The output for the above code is:

Tailwind CSS Display

flex: The flex class is a lot responsive and versatile or we can say mobile-friendly. It is not difficult to situate child elements and the main container. The margin doesn't implode with the content margins. The order for any element can be effortlessly different without altering the HTML area (section).

Syntax:

<element display="flex">...</element>

Example 4:

Code is as follows:

<!DOCTYPE html> 
<head> 
<link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" 
rel="stylesheet"> 
</head> 
<body class="text-center"> 
<center>
<h1 class="text-red-600 text-5xl font-bold">
Tutorial and Example
</h1> 
<b>flex Class - Tailwind CSS </b> 
<div class="flex bg-red-200 p-4 mx-16 ">
<div class="flex-1 bg-red-500 rounded-lg">1</div>
<div class="flex-1 bg-red-500 rounded-lg">2</div>
<div class="flex-1 bg-red-500 rounded-lg">3</div>
</div> 
</center>
</body> 
</html>

The output for the above code is:

Tailwind CSS Display