CSS 固定底部tabbar遮挡页面内容如何解决?

2023-06-10 177 0

自定义的tabbar组件
css

.k-tabbar {
  display: flex;
  justify-content: space-around;
  font-size: 12px;
  z-index: 999;
  padding-top: 10px;
  left: 0;
  position: fixed;
  bottom: 0;
  width: 100%;
  background-color: $blue;
  &-red {
    background: $red;
  }
  .tabbar-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 50px;
    color: #bbb;
    &.active {
      color: #fff;
    }
  }
}

html

 <view class="k-tabbar" :class="curThemeType == '蓝色海洋' ? '' : 'k-tabbar-red'">
    <template v-for="item in tabData">
      <view :key="item.name" class="tabbar-content" :class="item.name == tabName ? 'active' : ''"
        @click="handleClick(item.path)">
        <u-icon :name="item.icon" :color="item.name == tabName ? '#fff' : '#bbb'"></u-icon>
        <view>{{ item.title }}</view>
      </view>
    </template>
  </view>

tabbar 组件引入到 其他页面的时候 总是遮挡底部内容

image.png
这种问题怎么解决 能让页面内容高度auto 并且不被遮挡住

.page-content {
  padding-bottom: 50px;
}
或者
.page-content {
  margin-bottom: 50px;
}

CSS 有一个 safe-area 的概念,可以参考

JELLY | 网页适配 iPhoneX,就是这么简单

env() - CSS: Cascading Style Sheets | MDN

回答

相关文章

nuxt2部署静态化和ssr的时候访问首页先报404再出现首页为什么?
`clip-path` 如何绘制圆角平行四边形呢?
多线程wait方法报错?
VUE 绑定的方法如何直接使用外部函数?
vue2固定定位该怎么做?
谁有redis实现信号量的代码,希望借鉴一下?