<view class="nav_max" style="height:{{statusBarHeight}}px;">
<view class="nav_text" style="height:{{titleBarHeight}}px;
top:{{statusBarHeight}};line-height:{{titleBarHeight}}px;">标题</view>
</view>
page.js
onLoad: function (options) {
my.getSystemInfo({
success: (res) => {
this.setData({
statusBarHeight: res.statusBarHeight, //状态栏高度
titleBarHeight: res.titleBarHeight, //标题栏高度
})
}
})
}
page.acss
.nav_max {
position: fixed;
top: 0rpx;
left: 0rpx;
right: 0rpx;
opacity: 1;
z-index: 1;
display: flex;
align-items: center;
}
.nav_text {
flex: 1;
font-size: 32rpx;
height: 39px;
line-height: 39px;
color: #fff;
text-align: center;
font-weight: 700;
}
page.json
{
"allowsBounceVertical": "YES"
"transparentTitle": "always",
"titlePenetrate":"YES"
}