Layout

Floats

Utilities for controlling the wrapping of content around an element.

Quick reference

Class
Properties
float-rightfloat: right;
float-leftfloat: left;
float-nonefloat: none;

Basic usage

Floating elements to the right

Use float-right to float an element to the right of its container.

Floats - 图1

  1. <img class="float-right ..." src="path/to/image.jpg">
  2. <p>Maybe we can live without libraries, people like you and me. ...</p>

Floating elements to the left

Use float-left to float an element to the left of its container.

Floats - 图2

  1. <img class="float-left ..." src="path/to/image.jpg">
  2. <p>Maybe we can live without libraries, people like you and me. ...</p>

Disabling a float

Use float-none to reset any floats that are applied to an element. This is the default value for the float property.

Floats - 图3

  1. <img class="float-none ..." src="path/to/image.jpg">
  2. <p>Maybe we can live without libraries, people like you and me. ...</p>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:float-right to only apply the float-right utility on hover.

  1. <img class="float-right hover:float-left" src="path/to/image.jpg">

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:float-right to apply the float-right utility at only medium screen sizes and above.

  1. <img class="float-right md:float-left" src="path/to/image.jpg">

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.