---
url: /components/affix.md
---
# Affix 图钉

将页面元素钉在可视区间：滚动越过后固定在 `offset` 指定的距顶/距底位置，常用于表格工具栏、操作条的常驻。

## 基础用法

## 指定滚动容器

默认监听 window；钉在内部滚动容器时传 `target`：

```vue
<eb-affix :offset="0" target="#detail-scroll-container">
  <section-card>区块操作条</section-card>
</eb-affix>
```

## Affix API

| 名称 | 类型 | 默认值 | 说明 |
| --- | --- | --- | --- |
| offset | Number | `0` | 距顶/距底的偏移（px） |
| position | String | `top` | 钉住方向：top / bottom |
| target | String | window | 滚动容器选择器 |
| z-index | Number | `100` | 固定态层级 |

事件：`change(affixed)`。
