BackTop

返回页面顶部的操作按钮。

设计文档(新窗口打开)

代码演示

如何引入

import { BackTop } from '@chenzy-design/svelte';

基本用法

BackTop 预设了基本的返回按钮,可以直接调用。

向下滚动容器,右下角出现灰色返回按钮。
Scroll down to see the bottom-right gray button.

自定义样式

BackTop 预设了默认样式,包括:距离底部 50px、距离右侧 100px、box-sizing 为 border-box、内容水平居中。样式可以覆盖。

向下滚动容器,右下角出现蓝色圆形按钮。
Scroll down to see the bottom-right blue circular button.

API 参考

属性说明类型默认值
class类名string-
duration滚动到顶部的时间number450
style样式string-
target返回需要监听其滚动事件的元素对应 DOM 元素的函数() => HTMLElement \| Window() => window
visibilityHeight出现 BackTop 需要达到的滚动高度number400
onClick点击事件的回调函数(e: MouseEvent) => void-

设计变量

变量
默认值
用法
--cd-backtop-z var(--cd-z-affix) 按钮 z-index(对齐 Semi $z-backtop: 10)
显示第 1 条-第 1 条,共 1 条
  • 1