uniapp在安卓和iso的底部安全距离
padding-bottom: calc(底部距离rpx);
padding-bottom: calc(底部距离rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(底部距离rpx + env(safe-area-inset-bottom));
env()和constant(),是IOS11新增特性,Webkit的css函数,用于设定安全区域与边界的距离,有4个预定义变量:
safe-area-inset-left:安全区域距离左边边界的距离
safe-area-inset-right:安全区域距离右边边界的距离
safe-area-inset-top:安全区域距离顶部边界的距离
safe-area-inset-bottom :安全距离底部边界的距离
uniapp在安卓和iso、微信的顶部距离
padding-top: var(--status-bar-height) ;//给组件加个上边距
或者写一个占位div,高度设为css变量
height: var(--status-bar-height);
<style lang="scss" scoped>
.goodsListContainer {
/* #ifdef APP-PLUS */
padding-top: var(--status-bar-height);
height: calc(100vh - var(--status-bar-height)) ;
/* #endif */
/* #ifdef MP */
padding-top:calc(var(--status-bar-height) + 40rpx);
/* #endif */
min-height: 100vh;
</style>
复制代码