fixed 定位 top设置为0,但是竟然跟微信顶部bar隔了一点空隙

发布于 7 年前作者 juanfang2839 次浏览最后编辑 7 年前来自 ask
  • 当前 Bug 的表现(可附上截图)

position:fixed;top:0;

底部其实是一些列表,列表有几个图片,然后上下滚动,会有时候出现图示,穿透了,这个是怎么回事呢?小米8手机

  • 预期表现

  • 复现路径

  • 提供一个最简复现 Demo

<view class=‘ceshi’>dddd </view>

.ceshi{

position: fixed;

top: 0;

left: 0;

right: 0;

z-index: 10;

height: 100rpx;

background-color: #fff;

}

2 回复
yan35
yan352 楼5 年前

这个确实在部分机型上会出现这个问题,所以,可以这样干:

.ceshi{
  position: fixed;
  top: -4rpx;
  left: 0;

  right: 0;

 padding-top: 4rpx;

  z-index: 10;
  height: 100rpx;
  background-color: #fff;
}