美文网首页
小程序全面屏适配

小程序全面屏适配

作者: nucky_lee | 来源:发表于2020-03-11 19:39 被阅读0次

basic.less(全局样式)中:

page {

  // height: 100%; // 不要加 height: 100%;

  padding-bottom: constant(safe-area-inset-bottom); // 适配全面屏

  padding-bottom: env(safe-area-inset-bottom);

}

// 如果页面底部有固定button,高度为120rpx,加此下代码

.has-button-padding {

  padding-bottom: 120rpx !important;

}

页面底部button组件bottomButton:

<view class="bottomButton"></view>
  .bottomButton {

    position: fixed;

    bottom: 0;

    width: 100%;

    height: 120rpx;

    padding-bottom: constant(safe-area-inset-bottom);

    padding-bottom: env(safe-area-inset-bottom);

  }

如果页面内容不限制高度,则正常添加如上适配就行。如果限制一屏高度,如下图:

CE9CEB8E-B626-4A9A-B7C0-DBDA5B7E5313.png
<div class="crm-other-container has-button-padding">

  <van-tree-select items="{{ infoItems }}" main-active-index="{{ mainActiveIndex }}" active-id="{{ activeId }}"          bind:clicknav="onClickNav" bind:clickitem="onClickItem" />

  <bottomButton btnArr="{{ btnArr }}" />

  <van-toast id="van-toast" />

</div>
<style lang="less">

  .crm-other-container {

    box-sizing: border-box;

    height: 100%;

  .van-tree-select {

    height: calc(100vh - 120rpx - constant(safe-area-inset-bottom)) !important;

    height: calc(100vh - 120rpx - env(safe-area-inset-bottom)) !important;

    overflow-y: auto; // 属性规定是否对内容的上/下边缘进行裁剪 - 如果溢出元素内容区域的话,则提供滚动机制

  }

}
</style>
关于height:100%和height:100vh的区别

vh就是当前屏幕可见高度的1%,也就是说

height:100vh == height:100%;

但是当元素没有内容时候,设置height:100%,该元素不会被撑开,此时高度为0,

但是设置height:100vh,该元素会被撑开屏幕高度一致。

相关文章

  • 小程序全面屏适配

    basic.less(全局样式)中: 页面底部button组件bottomButton: 如果页面内容不限制高度,...

  • 小程序全面屏底部按钮适配

    如果你的小程序页面按钮有用fixed定位到底部的话,那你一定会遇到兼容全面屏的坑(与底部横条重叠)。查了下文档,发...

  • iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案

    iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案 iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案

  • Android适配之版本适配

    这篇文章用来记录学习和开发时遇到的版本适配问题,持续更新 全面屏、刘海屏的适配:Android 9 支持最新的全面...

  • Android Studio 图片适配/使用之SVG

    前言 适配可以说是Android的老大难问题了,Android厂商众多,设备碎片化严重.大屏小屏,全面屏,异形屏数...

  • 全面屏适配

    简单记录一下,预备知识来源:安卓屏幕完美适配方案——独家秘笈 先来点预备知识 屏幕尺寸(in) 手机对角线的物理尺...

  • 全面屏适配

    官方方法 只需要在application中添加

  • 全面屏适配

    https://www.jianshu.com/p/20d24c31cf5f[https://www.jiansh...

  • iOS解决无法适配模拟器的问题

    最近要进行全面屏的适配,但是又没有全面屏手机,全面屏手机价格太高,申请一个全面屏测试机估计也没有希望,所以只能使用...

  • 2018-11-29

    iOS 关于全面屏适配的方案及UI在不同尺寸下适配方案 - 掘金

网友评论

      本文标题:小程序全面屏适配

      本文链接:https://www.haomeiwen.com/subject/okbhjhtx.html