Tailwind CSS Box Sizing

Tailwind CSS Box sizing class acknowledges more than one worth in tailwind CSS. Each property is shrouded as a class structure. It is an option in contrast to the CSS box-sizing property. This class is utilized to characterize how the client(user) ought to work out the all-out width and tallness(height) of a component for example padding and borders, are to be incorporated or not.

There are two categorizes of box sizing, which includes:

  • box-border
  • box-content

box-border

In this mode, the width and height properties incorporate content, padding, and borders. For example, assuming that we set a component's/elements width to 200 pixels, that 200 pixels will incorporate any border or padding we add, and the content box will retain that additional width. This regularly makes it a lot simpler to measure components (elements).

Syntax:

<element class="box-border">..</element>

Code Example

Code is as follows:

<!DOCTYPE html> 


<head> 


    <title>Tailwind box-border Class of CSS</title> 


    <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>box-border Class of Tailwind CSS</b> 


    <div class="box-border h-28 w-32 p-4 


                border-4 bg-red-500 m4">


        An Interview Qns Portal


    </div> 


</center>


</body> 


 </html>

Output

The output for the above code is:

Tailwind CSS Box Sizing

box-content

This is the default value of the box-sizing class. In this mode, the width and height class incorporate the content. Border and padding are excluded from it i.e. if we set an element's width to 200 pixels, the component's content-box will be 200 pixels wide, and the width of any border or padding will be added to the last delivered width.

Syntax:

<element class="box-content">..</element>

Code Example

Code is as follows:

<!DOCTYPE html> 


<head> 


    <title>Tailwind box-content Class</title> 


    <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>box-content Class Tailwind CSS</b> 


    <div class="box-content h-28 w-32 p-4 


                border-4 bg-red-500 m4">


        An Interview Questions Portal


    </div> 


</center>


</body> 


</html>

Output

The output for the above code is:

Tailwind CSS Box Sizing