置顶或置底

基本案例

当页面滚动时,元素超过窗口顶部(底部)时,会固定显示在顶部(底部)。

在需要置顶或置底的元素上添加.fixed样式,默认为置顶,当设置data-style属性值为fixed-bottom时,则为置底。

别离开我,我要回去。

我先在底部呆着,到站了才回去。

参数

置顶或置底参数包含置顶样式data-style和偏离值data-offset-fixed

参数 类型 默认值 可选值 说明
data-style 字符串 fixed-top fixed-top 元素置顶,如:data-style="fixed-top"
fixed-bottom 元素置底,如:data-style="fixed-bottom"
data-offset-fixed 整数 0 偏离的高底值,如data-offset-fixed="10",单位为px。