Overscroll Behavior

Utilities for controlling how the browser behaves when reaching the boundary of a scrolling area.

Default class reference

Class
Properties
overscroll-autooverscroll-behavior: auto;
overscroll-containoverscroll-behavior: contain;
overscroll-noneoverscroll-behavior: none;
overscroll-y-autooverscroll-behavior-y: auto;
overscroll-y-containoverscroll-behavior-y: contain;
overscroll-y-noneoverscroll-behavior-y: none;
overscroll-x-autooverscroll-behavior-x: auto;
overscroll-x-containoverscroll-behavior-x: contain;
overscroll-x-noneoverscroll-behavior-x: none;

Auto

Use overscroll-auto to make it possible for the user to continue scrolling a parent scroll area when they reach the boundary of the primary scroll area.

Overscroll Behavior - 图1

  1. <div class="overscroll-auto ...">Lorem ipsum dolor sit amet...</div>

Contain

Use overscroll-contain to prevent scrolling in the target area from triggering scrolling in the parent element, but preserve “bounce” effects when scrolling past the end of the container in operating systems that support it.

Overscroll Behavior - 图2

  1. <div class="overscroll-contain ...">Lorem ipsum dolor sit amet...</div>

None

Use overscroll-none to prevent scrolling in the target area from triggering scrolling in the parent element, and also prevent “bounce” effects when scrolling past the end of the container.

Overscroll Behavior - 图3

  1. <div class="overscroll-none ...">Lorem ipsum dolor sit amet...</div>

Responsive

To control the overscroll-behavior property at a specific breakpoint, add a {screen}: prefix to any existing overscroll-behavior utility. For example, use md:overscroll-contain to apply the overscroll-contain utility at only medium screen sizes and above.

  1. <div class="overscroll-auto md:overscroll-contain lg:overscroll-none ...">
  2. <!-- ... -->
  3. </div>

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

Customizing

Variants

By default, only responsive variants are generated for overscroll-behavior utilities.

You can control which variants are generated for the overscroll-behavior utilities by modifying the overscrollBehavior property in the variants section of your tailwind.config.js file.

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

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. extend: {
  5. // ...
  6. + overscrollBehavior: ['hover', 'focus'],
  7. }
  8. }
  9. }

Disabling

If you don’t plan to use the overscroll-behavior utilities in your project, you can disable them entirely by setting the overscrollBehavior property to false in the corePlugins section of your config file:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + overscrollBehavior: false,
  6. }
  7. }

←Overflow Position→

Edit this page on GitHub