Class reference

Position - 图1

Static Default

Use .static to position an element according to the normal flow of the document.

Any offsets will be ignored and the element will not act as a position reference for absolutely positioned children.

Position - 图2

Relative

Use .relative to position an element according to the normal flow of the document.

Offsets are calculated relative to the element’s normal position and the element will act as a position reference for absolutely positioned children.

Position - 图3

Absolute

Use .absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

Offsets are calculated relative to the nearest parent that has a position other than static, and the element will act as a position reference for other absolutely positioned children.

Position - 图4

Fixed

Use .fixed to position an element relative to the browser window.

Offsets are calculated relative to the viewport and the element will act as a position reference for absolutely positioned children.

Position - 图5

Sticky

Position - 图6

Use .sticky to position an element as relative until it crosses a specified threshold, then treat it as fixed until its parent is off screen.

Offsets are calculated relative to the element’s normal position and the element will act as a position reference for absolutely positioned children.

Position - 图7

Pinning edges

Use the .pin{-edge?} utilities to anchor absolutely positioned elements against any of the edges of the nearest positioned parent.

Combined with Tailwind’s spacing utilities, you’ll probably find that these are all you need to precisely control absolutely positioned elements.

Class

Position - 图8

Edge (optional)

Position - 图9

All (default)

Position - 图10

Top

Position - 图11

Right

Position - 图12

Bottom

Position - 图13

Left

Position - 图14

Top and Bottom

Position - 图15

Left and Right

Position - 图16

Responsive

To position an element only at a specific breakpoint, add a {screen}: prefix to any existing positioning utility. For example, adding the class md:absolute to an element would apply the absolute utility at medium screen sizes and above, and adding lg:pin-y would apply pin-y at large screens and above.

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Position - 图17

all

Position - 图18

sm

Position - 图19

md

Position - 图20

lg

Position - 图21

xl

Position - 图22

Customizing

Responsive and State Variants

By default, only responsive variants are generated for positioning utilities.

You can control which variants are generated for the positioning utilities by modifying the position property in the modules section of your Tailwind config file.

For example, this config will also generate hover and focus variants:

Position - 图23

Disabling

If you don’t plan to use the positioning utilities in your project, you can disable them entirely by setting the position property to false in the modules section of your config file:

Position - 图24