Layout

Clear

Utilities for controlling the wrapping of content around an element.

Quick reference

Class
Properties
clear-leftclear: left;
clear-rightclear: right;
clear-bothclear: both;
clear-noneclear: none;

Basic usage

Clearing left-floated elements

Use clear-left to position an element below any preceding left-floated elements.

Clear - 图1

  1. <img class="float-left ..." src="path/to/image.jpg">
  2. <img class="float-right ..." src="path/to/image.jpg">
  3. <p class="clear-left ...">Maybe we can live without libraries...</p>

Clearing right-floated elements

Use clear-right to position an element below any preceding right-floated elements.

Clear - 图2

  1. <img class="float-left ..." src="path/to/image.jpg">
  2. <img class="float-right ..." src="path/to/image.jpg">
  3. <p class="clear-right ...">Maybe we can live without libraries...</p>

Clearing all floated elements

Use clear-both to position an element below all preceding floated elements.

Clear - 图3

  1. <img class="float-left ..." src="path/to/image.jpg">
  2. <img class="float-right ..." src="path/to/image.jpg">
  3. <p class="clear-both ...">Maybe we can live without libraries...</p>

Disabling applied clears

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

Clear - 图4

  1. <img class="float-left ..." src="path/to/image.jpg">
  2. <img class="float-right ..." src="path/to/image.jpg">
  3. <p class="clear-none ...">Maybe we can live without libraries...</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:clear-none to only apply the clear-none utility on hover.

  1. <p class="clear-left hover:clear-none">
  2. <!-- ... -->
  3. </p>

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:clear-none to apply the clear-none utility at only medium screen sizes and above.

  1. <p class="clear-left md:clear-none">
  2. <!-- ... -->
  3. </p>

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