当前位置:网站首页>【微信小程序】底部有安全距离,适配iphone X等机型的解决方案
【微信小程序】底部有安全距离,适配iphone X等机型的解决方案
2022-08-03 08:15:00 【少年歌行s】
微信小程序开发常常需要适配机型问题,如iPhone X/XR等机型,底部有黑色横杠(称为安全距离),这时如果直接加css样式fixed是不行的,不会计算底部安全距离,而会与之重叠。
// fixed .box {
position: fixed;
bottom: 0;
}


经过搜索后,我们知道env(safe-area-inset-bottom)能计算出安全距离,我想到一个通用的写法,具体做法是将页面高度page的高度限制为屏幕高度减去安全距离,代码实现是calc(100vh- env(safe-area-inset-bottom))
完整代码如下:
<scroll-view class="container" scoll-y="{
{true}}">
//正常html代码
</scroll-view>
page {
height: calc(100vh- env(safe-area-inset-bottom));
overflow: hidden;
}
//要给高度,不然scroll-view无法垂直方向滑动 .container {
height: 100%;
}
边栏推荐
- [Kaggle combat] Prediction of the number of survivors of the Titanic (from zero to submission to Kaggle to model saving and restoration)
- frp:开源内网穿透工具
- Neo4j 4.X:导入OWL文件
- C# 一周入门高级编程之《C#-继承》Day One
- Eject stubborn hard drives with diskpart's offline command
- Qt5开发从入门到精通——第二篇(控件篇)
- Redis的基础与django使用redis
- 【收获合辑】k-NN与检索任务的异同+jupyter转pdf
- Unity编辑器扩展批量修改图片名称
- 前缀和(区间和,子矩阵的和)
猜你喜欢

并发之多把锁和活跃性

AI mid-stage sequence labeling task: three data set construction process records

Charles抓包工具学习记录
![[ 漏洞复现篇 ] yapi 代码执行 getshell 漏洞复现详解](/img/85/a4142689c22492cd898bd8275cd2c5.png)
[ 漏洞复现篇 ] yapi 代码执行 getshell 漏洞复现详解

Shell运维开发基础(一)

Redisson实现分布式锁

The use of the database table structure document generation tool screw

开发工具之版本控制

mysql5.7服务器The innodb_system data file 'ibdata1' must be writable导致无法启动服务器

WordPress主题-B2美化通用子主题商业运营版
随机推荐
wordpress: 裁剪您的图片时发生错误
AI中台序列标注任务:三个数据集构造过程记录
MySQL2
CSP-S2019 Day2
获取JDcookie的方法
《剑指Offer》刷题之打印从1到最大的n位数
001-进程与线程
服务器资源监控工具-nmon、nmon_analyser
NFT到底有哪些实际用途?
Unity关于编辑器扩展自定义标签,方便扩展Inspector
MySQL or使索引失效
【愚公系列】2022年07月 Go教学课程 026-结构体
PowerShell:执行 Install-Module 时,不能从 URI 下载
Exch:重命名或删除默认邮箱数据库
Docker启动mysql
解决GANs训练中模式崩塌/训练崩溃的十五个方法
基于SSM开发的的小区物业管理系统小程序源码
"Swordsman Offer" brush questions print from 1 to the largest n digits
Mysql如何对两张表的相同字段,同时查询两张数据表
并发之ReentrantLock