页面底部固定显示按钮,同时不覆盖页面内容

在页面底部添加按钮,并让它始终保持在页面底部,不随着下拉而改变位置,同时按钮不能覆盖页面内容。

效果图如下:

首先实现固定按钮在底部:

<View className='navigate-container'>
  <View className='at-row'>
    <AtButton className='AtButton button_last' onClick={() => {Taro.navigateBack()}}>返回</AtButton>
    <AtButton className='AtButton button_next' onClick={this.handleSubmit}>下一步</AtButton>
  </View>
</View>
.navigate-container {
  position: fixed;
  bottom: 0;
  width: 100%;
  background-color: #ffffff;
  padding: 10rpx;
  box-shadow: 0rpx -2rpx 5rpx 0rpx rgba(0,0,0,0.1);
  z-index: 999;
}

此时存在的问题就是当页面滑到底部时,按钮会覆盖页面内容。

  

解决方法:

直接在页面之中添加一个Veiw,使其占据一定的高度,从而使页面内容能够完整显示。

<View className='placeholder-view' />
.placeholder-view {
  width: 100%;
  height: 120rpx;
}

完整代码如下:

<View className='placeholder-view' />
<View className='navigate-container'>
  <View className='at-row'>
    <AtButton className='AtButton button_last' onClick={() => {Taro.navigateBack()}}>返回</AtButton>
    <AtButton className='AtButton button_next' onClick={this.handleSubmit}>下一步</AtButton>
  </View>
</View>
.placeholder-view {
  width: 100%;
  height: 120rpx;
}

.navigate-container {
  position: fixed;
  bottom: 0;
  width: 100%;
  background-color: #ffffff;
  padding: 10rpx;
  box-shadow: 0rpx -2rpx 5rpx 0rpx rgba(0,0,0,0.1);
  z-index: 999;
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值