当前位置:网站首页>【微信小程序】底部有安全距离,适配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)](/img/2b/d2f565d9221da094a9ccc30f506dc8.png)
[Kaggle combat] Prediction of the number of survivors of the Titanic (from zero to submission to Kaggle to model saving and restoration)

数仓4.0(一)

【愚公系列】2022年07月 Go教学课程 026-结构体

How does Mysql query two data tables for the same fields in two tables at the same time

审批流设计

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

requests库

redis键值出现 xacxedx00x05tx00&的解决方法

积分商城系统设计

数据监控平台
随机推荐
Add Modulo 10 (规律循环节,代码实现细节)
Transformer、BERT、GPT 论文精读笔记
Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
The use of the database table structure document generation tool screw
HCIP练习03(重发布)
MySQL1
牛客 - 最佳直播时间 (差分)
并发之固定运行和交替运行方案
sqlserver2019安装失败
JMeter接口自动化发包与示例
redis AOF持久化个人理解
推荐系统-排序层-模型:Wide&Deep
【论文笔记】一种基于启发式奖赏函数的分层强化学习方法
Shell运维开发基础(一)
mysql的innodb存储引擎和myisam存储引擎的区别
requests库
分析型数据库性能测试总结
“唯一索引允许为空“ 的说法是不严谨的
ArcEngine(一)加载矢量数据
Evaluate:huggingface评价指标模块入门详细介绍