当前位置:网站首页>小程序页面设置100%高度还是留白怎么办?
小程序页面设置100%高度还是留白怎么办?
2022-06-28 06:26:00 【痴心阿文】
本文前言:小程序页面设置100%高度还是留白怎么办?像小程序,app开发的时候经常会遇到设置高度,页面颜色的问题,经常出现留白没占满现象,今天专门整了一篇文章,解决这个问题。
页面设置背景色
"pages": {
"navigationBarBackgroundColor": "#32A2FD", // 顶部背景颜色
"navigationBarTitleText": "123456", // 顶部文字
"navigationStyle": "default", // 是否自定义导航栏,当"default"为"custom"时开启自定义头部导航栏选项
"navigationBarTextStyle": "white", // 顶部文字颜色 仅支持 white/black
"enablePullDownRefresh": true, // 开启下拉刷新, 在单个页面设置为"false",在使用页面会覆盖掉当前设置
"backgroundTextStyle":"light" // 下拉背景字体、loading 图的样式,仅支持 dark/light
},
第一种方法:position: fixed; 优点,占满全部不留白,缺点,页面固定不能滑动
box:{
height: 100%;
width: 100%;
background-color: #fff;
position: fixed;
}
第二种,页面高度设置100vh
box:{
height: 100%;
width: 100vh;
background-color: #fff;
}
顺便说下100%和100vh的区别:
vh就是当前屏幕可见高度的1%,也就是说100vh == 100%,
如果当元素没有内容的时候,设置height:100%该元素不会被撑开,
设置height:100vh,该元素会被撑开屏幕高度一致。
如果觉得博主的文章有帮到你的话,请支持一下博主哦
额外写点其他的,最近小程序用的比较多,三元运算符
表达式1 ? 表达式1为true时的结果 : ( 表达式2 ? 表达式2为true时的结果 : 全都是false的结果 )
if (this[types == 10 ? 'lastPage':(types == 11?'lastPage2':'lastPage3')] && page != 0) return
this[types == 10 ? 'page' :(types == 11?'page2':'page3') ] += page
边栏推荐
猜你喜欢
Linked list (III) - reverse linked list
Linux MySQL implements root user login without password
移动广告发展动向:撬动存量,精细营销
链表(二)——设计链表
Iframe switching in Web Automation
MySQL(一)——安装
Paper recommendation: efficientnetv2 - get smaller models and faster training speed through NAS, scaling and fused mbconv
RN7302三相电量检测(基于STM32单片机)
Error reporting - resolve core JS / modules / es error. cause. JS error
Slow content advertising: the long-term principle of brand growth
随机推荐
助力涨点 | YOLOv5结合Alpha-IoU
Enum
Configure redis from 0
使用SQL select count distinct查询语句统计数据库中某个字段的唯一值总数量
FPGA - 7 Series FPGA selectio -07- iserdese2 of advanced logic resources
Create a gson object that formats the time zone. JSON parsing time formatting zoneddatetime
Unity packaging webgl uses IIS to solve the error
YYGH-BUG-02
语音增强-频谱映射
freeswitch使用mod_shout模块播放mp3
FPGA - 7 Series FPGA selectio -08- oserdese2 of advanced logic resources
Scripting and programming languages
Taobao seo training video course [22 lectures]
Teach you how to use UCOS
FPM tool installation
链表(二)——设计链表
Uni app wechat applet sharing function
API learning of OpenGL (2006) glclientactivetexture
Yolact++ Pytorch环境
Some habits of it veterans in the workplace