uniapp-自定义导航栏时距离顶部太靠近如何解决?

1.在pages.json中设置navigationStyle为custom

{
  "path": "pages/views/index",
  "style": {
    "navigationBarTitleText": "首页",
    "navigationStyle": "custom"
  }
},

2.非H5端,手机顶部状态栏区域会被页面内容覆盖。这是因为窗体是沉浸式的原因,即全屏可写内容。uni-app提供了状态栏高度的css变量–status-bar-height,如果需要把状态栏的位置从前景部分让出来,可写一个占位div,高度设为css变量。

<template>
  <view>
      <view class="status_bar"></view>
      <view class="customContent"> 自定义导航内容</view>
  </view>
</template>    
<style lang="scss" scoped>
.status_bar {
    height: var(--status-bar-height);
    width: 100%;
    position: fixed;
    top: 0;
    background: #fff;
    z-index: 998;
}
.customContent {
   position: fixed;
   height: 88rpx;
   background: #fff;
   top:var(--status-bar-height);
   width: 100%;
   z-index: 998;
   border-bottom: 2rpx solid #eee;
}
</style>

更多详见自定义导航栏

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值