苹果手机顶部安全区兼容

问题:

如图所示,标题与ios安全区域没有分开。

解决方式:

写一个div,使它高度与Ios安全区一致。将其余内容挤压到安全区下

具体代码如下

<template>
  <div class="quiz-edit">
    <div class="top">
      <div class="van-safe-area-inset-top"></div>//该div置于安全区内
      <div class="nav-bar">
        <van-icon name="arrow-left" class="left" :size="20" @click="onClickLeft"/>
        <div class="center">
          <span class="title">问题编写</span>
          <span class="tips">可使用提问次数:4次</span>
        </div>
        <span class="myquiz" @click="onClickRight">我的提问</span>

      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>

// 苹果手机顶部安全区 兼容
@supports (top: env(safe-area-inset-top)) {
  .van-safe-area-inset-top {
    height: constant(safe-area-inset-top);
    height: env(safe-area-inset-top);
  }
}

.quiz-edit{
  overflow: hidden;
  // height: 45px;
}
.top{
  background: #fe484a;
  height: 45px;
  padding: 0 15px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 999998;
  .van-safe-area-inset-top {
    width: 100%;
    background-color: #fe484a;
  } 
  .nav-bar{
    display: flex;
    .left{
      color: #fff;
      line-height: 45px;
      width: 24px;
      height: 24px;
    }
    .center{
      position: absolute;
      left: 50%;
      width: 60%;
      margin-left: -31%;
      height: 45px;
      z-index: 99999999;
      color: #fff;
      overflow: hidden;
      text-align: center;
      .title{
        display: block;
        // width: 30%;
        font-size: 16px;
        line-height: 16px;
        padding-top: 8px;
        margin-left: 5%;
        z-index: inherit;
      }
      .tips{
        display: block;
        margin-top: 5px;
        font-size: 12px;
        text-align: center;
        z-index: 999999;
      }
    }

    .myquiz{
      line-height: 45px;
      font-size: 14px;
      z-index: 999999;
      position: absolute;
      // top: 0;
      right: 15px;
      color: #fff;
      }
  }

}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值