> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/guide/ui/scrolling.md.

# 管理滚动

溢出行为是指元件的内容（自身内容与子元件）超出了元件自身的大小，在搭建页面的过程中不可避免的会遇到溢出的情况。
你可以通过 [`overflow`](/zh/api/css/properties/overflow.md) 属性来裁切溢出的内容,
也可以通过[滚动容器](#滚动容器)来让溢出的内容可以滚动，并通过 `scroll-orientation` 属性来控制内容的滚动方向：

非滚动容器
滚动容器
| ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/style-guide-overflow-visible.png) | ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/style-guide-overflow-hidden.png) | ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/guide-scroll-orientation-vertical.gif) | ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/guide-scroll-orientation-horizontal.gif) |
| 发生了内容溢出 | 通过 
`overflow: hidden
` 裁切溢出内容 | `scroll-orientation: vertical
` 的纵向滚动容器 | `scroll-orientation: horizontal
` 的横向滚动容器 |


不支持`overflow:scroll`实现滚动效果`Lynx`中，`view` 组件不支持像 Web 中通过 `overflow:scroll`来实现滑动效果， 只有`<scroll-view>` 和 `<list>` 等滑动容器具备滑动效果。

## 滚动容器

对于一些 `<view>` 基础组件，不支持滚动效果，请使用专门的滚动容器元件 [`<scroll-view>`](/zh/api/elements/built-in/scroll-view.md) 或 [`<list>`](/zh/api/elements/built-in/list.md)。

### 使用 `<scroll-view>` 实现基础滚动

`<scroll-view>` 是 `Lynx` 中基础滚动组件，允许用户在固定的视窗区域内上下或左右滚动内容。以下图为例，当内部子节点高度超过了父容器 `<scroll-view>` 时，只需要将排版方向 `scroll-orientation` 设置为 `vertical` 就可以实现竖直方向的滚动效果。

**下面是一个示例: scroll-view**

**Entry:** `src/vertical`
**Bundle:** `dist/vertical.lynx.bundle` | Web: `dist/vertical.web.bundle`

```tsx {9}
import { root } from "@lynx-js/react";
import { VerticalScrollItem } from "../component/scrollItem.jsx";

const VerticalScrollContainer = () => {
  return (
    <view style={{ width: "100%", height: "100%" }}>
      <text className="title">ScrollView Example</text>
      <scroll-view
        scroll-orientation="vertical"
        style={{ width: "100%", height: "100%", paddingLeft: "10px", marginLeft: "5px" }}
      >
        {Array.from({ length: 20 }).map((item, index) => <VerticalScrollItem index={index} />)}
      </scroll-view>
    </view>
  );
};

root.render(<VerticalScrollContainer />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```



### 使用 `<list>` 处理大量数据

`<scroll-view>` 用于展示少量数据数据, 简单直观。`<list>` 则适合展示大量数据的场景，或者无限下滑加载更多场景，它能采用按需加载形式, 只渲染可见区域内容。

 
**下面是一个示例: list**

**Bundle:** `dist/base.lynx.bundle` | Web: `dist/base.web.bundle`

```tsx {12-14}
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root } from "@lynx-js/react";
import { ItemView } from "./baseView.jsx";

const ListContainer = () => {
  return (
    <list
      scroll-orientation="vertical"
      list-type="single"
      span-count={1}
      style={{
        width: "100%",
        height: "100vh",
        listMainAxisGap: "5px",
        padding: "10px",
      }}
    >
      {Array.from({ length: 50 }).map((item, index) => {
        return (
          <list-item
            item-key={`list-item-${index}`}
            key={`list-item-${index}`}
          >
            <ItemView index={index} />
          </list-item>
        );
      })}
    </list>
  );
};

root.render(<ListContainer />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```



### 使用 `<list>` 处理复杂布局

`<scroll-view>` 只具备线性布局的能力，通过线性排列让元件有序呈现。然而面对复杂的界面时，`<list>` 排版选项丰富，可以选择[网格和瀑布流](/zh/api/elements/built-in/list.md#required-list-type)等不同布局来灵活定制业务需求。

**下面是一个示例: list**

**Entry:** `src/waterfall`
**Bundle:** `dist/waterfall.lynx.bundle` | Web: `dist/waterfall.web.bundle`

```tsx {14-16}
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root } from "@lynx-js/react";

import "./index.scss";
import { ItemView } from "./baseView.jsx";

const ListContainer = () => {
  return (
    <list
      className="list-container"
      list-type="waterfall"
      span-count={2}
      scroll-orientation="vertical"
    >
      {Array.from({ length: 40 }).map((item, index) => {
        return (
          <list-item
            item-key={`list-item-${index}`}
            key={`list-item-${index}`}
          >
            <ItemView index={index} />
          </list-item>
        );
      })}
    </list>
  );
};

root.render(<ListContainer />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```



### 其他功能

- 吸顶能力：`<scroll-view>` [吸顶](/zh/api/elements/built-in/scroll-view.md#吸顶能力)；`<list>` [吸顶](/zh/api/elements/built-in/list.md#实现节点吸顶或者吸底)

- `<list>` [分页滚动](/zh/api/elements/built-in/list.md#利用-item-snap-实现分页滚动)

- `<list>` [下滑加载更多](/zh/api/elements/built-in/list.md#实现滚动到底部加载更多数据)
