mip-fixed 悬浮布局
悬浮元素整体使用方案。
| 标题 | 内容 |
|---|---|
| 类型 | 通用 |
| 支持布局 | N/S |
| 所需脚本 |
示例
顶部悬浮
123<mip-fixed type="top">
自定义内容,可以嵌套其他组件
</mip-fixed>顶部悬浮 - 向下滑动隐藏
123<mip-fixed type="top" data-slide>
顶部悬浮 - 向下滑动隐藏
</mip-fixed>顶部悬浮 - 自动隐藏距离
12345678910111213141516<!-- 以下代码只是示例 -->
<style>
/*元素顶部距离*/
.mip-fixed-top {
top: 300px !important;
}
/*自定义元素隐藏时动画*/
.mip-fixed-test-top {
-webkit-transform: translate3d(0, -400px, 0);
transform: translate3d(0, -400px, 0);
}
</style>
<mip-fixed type="top" data-slide="mip-fixed-test-top" class="mip-fixed-top">
顶部悬浮 - 自动隐藏距离
</mip-fixed>底部悬浮
123<mip-fixed type="bottom">
自定义内容,可以嵌套其他组件
</mip-fixed>左边悬浮
规则:属性 bottom 或 top 必须有一个
123<mip-fixed type="left" bottom="50px">
自定义内容,可以嵌套其他组件
</mip-fixed>右边悬浮
规则:属性 bottom 或 top 必须有一个
123<mip-fixed type="right" top="50px">
自定义内容,可以嵌套其他组件
</mip-fixed>支持 <mip-gototop>
123<mip-fixed type="gototop">
<mip-gototop></mip-gototop>
</mip-fixed>关闭悬浮元素的方法
给
<mip-fixed>标签添加一个自定义的id=customid。给需要点击关闭悬浮元素的标签添加属性
on="tap:customid.close"。
1234<mip-fixed type="top" id="customid">
<div>我是顶部的fixed</div>
<div class="btn_style" on="tap:customid.close">我是关闭按钮</div>
</mip-fixed>属性
type
说明:悬浮类型 必选项:是 类型:字符串 取值范围:top/bottom/right/left
top
说明:距离屏幕顶部距离 必选项: 否 类型:字符串 取值范围:数值+单位,例如:50(px|em|rem|vh|vw|vmin|vmax|cm|mm|q|in|pc|pt) 默认值:auto
bottom
说明:距离屏幕底部距离 必选项: 否 取值范围:数值+单位,例如:50(px|em|rem|vh|vw|vmin|vmax|cm|mm|q|in|pc|pt) 默认值:auto
data-slide
说明:屏幕向下滑动时元素添加 class 名称去隐藏元素,元素已经添加 transition: transform .5s ,只需要向对应的类添加 transform 即可,只支持 type="top" 和 type="bottom" 必须项:否 默认值:type="top" 时默认取值 mip-fixed-hide-top(translate3d(0, -200%, 0)) ,type="bottom" 时默认取值 mip-fixed-hide-bottom(translate3d(0, 200%, 0))
注意事项
悬浮类型
type为top,bottom类别不需要添加属性:top/bottom。type为left,right类别需要至少添加一个top/bottom属性,优先用bottom。type为gototop类别不需要任何属性。