Skip to main content Skip to docs navigation

溢出(Overflow)

使用这些速记工具可快速配置内容如何溢出元素。

On this page

概述

使用四种默认值和类别即时调整 overflow 属性。这些类默认情况下没有响应。

This is an example of using .overflow-auto on an element with set width and height dimensions. By design, this content will vertically scroll.
This is an example of using .overflow-hidden on an element with set width and height dimensions.
This is an example of using .overflow-visible on an element with set width and height dimensions.
This is an example of using .overflow-scroll on an element with set width and height dimensions.
<div class="overflow-auto">...</div>
<div class="overflow-hidden">...</div>
<div class="overflow-visible">...</div>
<div class="overflow-scroll">...</div>

overflow-x

调整 overflow-x 属性,以影响内容的水平溢出。

.overflow-x-auto example on an element
with set width and height dimensions.
.overflow-x-hidden example
on an element with set width and height dimensions.
.overflow-x-visible example
on an element with set width and height dimensions.
.overflow-x-scroll example on an element
with set width and height dimensions.
<div class="overflow-x-auto">...</div>
<div class="overflow-x-hidden">...</div>
<div class="overflow-x-visible">...</div>
<div class="overflow-x-scroll">...</div>

overflow-y

调整 overflow-y 属性,以影响内容的垂直溢出。

.overflow-y-auto example on an element with set width and height dimensions.
.overflow-y-hidden example on an element with set width and height dimensions.
.overflow-y-visible example on an element with set width and height dimensions.
.overflow-y-scroll example on an element with set width and height dimensions.
<div class="overflow-y-auto">...</div>
<div class="overflow-y-hidden">...</div>
<div class="overflow-y-visible">...</div>
<div class="overflow-y-scroll">...</div>

使用 Sass 变量,您可以通过更改 _variables.scss 中的 $overflows 变量来定制溢出工具。

CSS

Sass utilities API

溢出实用程序在 scss/_utilities.scss 中的实用程序 API 中声明。了解如何使用实用程序 API

"overflow": (
  property: overflow,
  values: auto hidden visible scroll,
),
"overflow-x": (
  property: overflow-x,
  values: auto hidden visible scroll,
),
"overflow-y": (
  property: overflow-y,
  values: auto hidden visible scroll,
),