×

Tailwind CSS Position

The position class acknowledges more than one value in tailwind CSS. It is an option in contrast to the CSS Position property. This class is utilized for controlling how an element is situated in the DOM.

Position classes

The various position classes in Tailwind CSS are classified as:

  • Static
  • Fixed
  • Absolute
  • Relative
  • sticky

static class

This class is utilized to set the place/position of an element as indicated by the ordinary flow of the document.

Syntax

<element class="static">...</element>

Example:

<!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>Position Class - Tailwind CSS </b>
<div class="static text-left p-2 m-2 bg-orange-200 h-48"> 
<p class="font-bold">Static Parent</p>
<div class="absolute bottom-0 left-0 p-2
bg-red-500">
<p>Absolute Child</p>
</div>
</div>
</center>
</body>
</html>

Output:

Tailwind CSS Position

fixed class

This class will be situated fixed to the viewport. An element with fixed situating permits it to stay at a similar position even we scroll the page. We can set the place/position of the element utilizing the top, right, bottom, left.

Syntax:

<element class="fixed">...</element>

Example:

<!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>Position Class - Tailwind CSS </b>
<div class="overflow-auto bg-red-200
mx-16 h-24 text-justify">
<div class="float-right fixed">
<p class="bg-red-500 p-2">
Tutorial and Example Fixed Child
</p>


</div>


<p>
How frequently were you baffled while
paying special attention to a decent assortment of
programming/calculation/inquiries questions?
What did you expect and what did you get?
This entrance has been made to give
elegantly composed, very much idea and 
well-clarified answers for chosen questions.
An IIT Roorkee former student and organizer of
Javatpoint. He loves to settle programming
Issues in most proficient ways. Aside from
Javatpoint, has worked with DE Shaw
, what's more, Co. as a product engineer and JIIT
Noida as an associate teacher. It is a
great stage to get the hang of programming. It is
an instructive site. Get ready for the
Enrolments drive of item-based organizations
like Microsoft, Amazon, Adobe, and so on with a
free web-based position arrangement course.
</p>


</div>
</center>
</body>


</html>

Output:

Tailwind CSS Position

In that above output, if we scroll the scrollbar up-down the content will scroll and the “Javatpoint Fixed Child” remain constant.

absolute class

This class is utilized to set the place/position of an element outside the normal flow of the document, making adjoining elements go about as though the element doesn't exist.

Syntax:

<element class="absolute">...</element>

Example:

<!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>Position Class - Tailwind CSS </b>
<div class="static text-left p-2 m-2 bg-red-200 h-48"> 
<p class="font-bold">Static parent</p>




<div class="absolute bottom-0 left-0 p-2
bg-red-500">


<p>Absolute child</p>


</div>
</div>
</center>
</body>
</html>

Output:

Tailwind CSS Position

relative class

This class is utilized to set the place/position of an element comparative with the ordinary/normal flow of the document.

Syntax:

<element class="relative">...</element>

Example:

<!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>Position Class - Tailwind CSS </b>
<div class="static text-left p-2 m-2 bg-red-200 h-48"> 
<p class="font-bold">Static parent</p>




<div class="relative p-2 inline-block
bg-red-500">


<p>Relative child</p>


</div>
<div class="relative p-2 inline-block
bg-red-600">


<p>Relative Sibling child</p>


</div>
</div>
</center>
</body>
</html>

Output:

Tailwind CSS Position

sticky class

This class is utilized to set the place/position of an element as relative until it passes a specific threshold, then, at that point, it regards it as fixed until its parent is off-screen.

Syntax

<element class="sticky">...</element>

Example:

<!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>Position Class - Tailwind CSS </b>
<div class="w-3/4 bg-red-200 h-24 overflow-auto">
<div>
<div class="p-2 sticky top-0 bg-red-500 text-right">
Sticky Heading - 1
</div>
<p class="py-4">
How frequently were you baffled while
paying special attention to a decent assortment of
programming/calculation/inquiries questions?
What did you expect and what did you get?
This entrance has been made to give
elegantly composed, very much idea and 
well-clarified answers for chosen questions.
</p>


</div>
<div>
<div class="p-2 sticky top-0 bg-red-500 text-right">
Sticky Heading - 2
</div>
<p class="py-4">
How frequently were you baffled while
paying special attention to a decent assortment of
programming/calculation/inquiries questions?
What did you expect and what did you get?
This entrance has been made to give
elegantly composed, very much idea and 
well-clarified answers for chosen questions.


</p>


</div>
<div>
<div class="p-2 sticky top-0 bg-red-500 text-right">
Sticky Heading - 3
</div>
<p class="py-4">
How frequently were you baffled while
paying special attention to a decent assortment of
programming/calculation/inquiries questions?
What did you expect and what did you get?
This entrance has been made to give
elegantly composed, very much idea and 
well-clarified answers for chosen questions.
</p>


</div>
</div>
</center>
</body>


</html>

Output (while scrolling the scrollbar we will see output like below):

Tailwind CSS Position Tailwind CSS Position Tailwind CSS Position Tailwind CSS Position Tailwind CSS Position


Related Topics

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...

5 minutes read.

Tailwind CSS Float

The float class acknowledges more than one worth (value) in tailwind CSS. It is an option in contrast to the CSS float property. The float class characterizes the progression of...

4 minutes read.

Tailwind CSS tutorial

Tailwind CSS can be utilized to make sites in the quickest and the least demanding way. Tailwind CSS is the most famous utility-first CSS structure on the planet for quickly...

4 minutes read.

Tailwind CSS Grid Auto Columns

The Grid Auto Columns class accepts multiple values, and all of the properties are covered in class form. It's a replacement for the CSS grid-auto-columns property. The size of the...

5 minutes read.

Tailwind CSS Flex Wrap

CSS flexbox is an important component for frontend development. It is a front-end development alternative to the CSS flex-wrap Property. Note: You must include the flex class in your element before...

4 minutes read.

Tailwind CSS Overflow

The overflow class acknowledges more than one value in Tailwind CSS. It is an option in contrast to the CSS Overflow property. This overflow is for controlling how element content...

9 minutes read.

Tailwind CSS Stroke Width

In tailwind CSS, this class takes a large number of values and all of the properties are covered in the form. It is used to specify the width of an...

1 minute read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 minutes read.

Tailwind CSS Place Items

This class accepts a wide range of values. It's a replacement for the CSS Place Items property. This class is used to manage how things are justified while still being...

4 minutes read.

Tailwind CSS Object Fit

It acknowledges more than one value in tailwind CSS. Every one of its properties is covered as in class form. It is the option in contrast to the CSS object-fit...

4 minutes read.

Tailwind CSS Justify Content

In tailwind CSS, this class accepts two values. It's a replacement for CSS's justify-content attribute. This class is used to describe the flexible box container's alignment. Along the main axis...

4 minutes read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.

Tailwind CSS Justify Self

The class form goes over the various properties. It's a replacement for the CSS justify-self attribute. This class is used to describe the alignment of content’s position in a CSS...

4 minutes read.

Tailwind CSS Padding

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Padding Property. This class is used...

4 minutes read.

Tailwind CSS Justify Items

It is a replacement for the CSS justify-items attribute. This class is used to regulate the alignment of grid objects along their inline axis. Justify Item It is classified as: justify-items-auto justify-items-start justify-items-end justify-items-center justify-items-stretch justify-items-auto The justify-items-auto class...

4 minutes read.

Tailwind CSS Max-Height

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Max-Height attribute. It is used to...

3 minutes read.

Tailwind CSS Container

In Tailwind CSS, a compartment is utilized to fix the maximum width (max-width) of a component to match the min-width of the breakpoint. It comes exceptionally convenient when content must...

2 minutes read.

Tailwind CSS Margin

The margin class accepts a large number of values, and all of the properties are covered in the same way they are in the class form. It's a replacement for...

6 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 minutes read.