当前位置:网站首页>H5 adaptive full screen
H5 adaptive full screen
2022-06-23 05:22:00 【* listen to the wind】
problem : Recently, with vue Development h5 When applied , When the form submit button is found at the bottom ,iPhone Native controls home indicator The bar will block the submit button , Here's the picture :
therefore , Full screen adaptation required , When it is judged to be a full screen , Add custom styles , Put the button a little higher .
utils.js The tool function to determine whether the screen is complete is encapsulated in :
// Check whether it is a full screen
export function checkFullScreen () {
let isFullScreen = false
const rate = window.screen.height / window.screen.width;
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65; // Critical value
// window.screen.availWidth: States the available width of the screen that displays the browser , In pixel . stay Windows In such an operating system , This available height does not include the assignment to semi permanent features ( Such as the taskbar at the bottom of the screen ) The vertical space of .
// window.screen.availHeight: Declares the available height of the screen that displays the browser , In pixel . stay Windows In such an operating system , This available height does not include the assignment to semi permanent features ( Such as the taskbar at the bottom of the screen ) The vertical space of .
// window.screen.width: Declares the width of the screen that displays the browser , In pixel .
// window.screen.height: Declares the height of the screen that displays the browser , In pixel .
if (rate > limit) {
isFullScreen = true;
}
return isFullScreen
}
then , After the tool function is introduced into the page, use :
<template>
<div class="btn-container" :class="{'full-screen':isFullScreen}">
<van-button :loading="submitLoading" block type="submit" color="linear-gradient(90deg, #2c2c2c 0%, #28beca 100%)" :disabled="!formData.name" native-type="submit"> Submit </van-button>
</div>
</template>
<script>
import {
checkFullScreen } from '@/utils/utils'
export default {
data() {
return {
submitLoading: false,
isFullScreen: checkFullScreen()
}
}
}
</script>
<style lang="less" scoped>
.full-screen {
padding-bottom: 0.42rem;
}
</style>
The page effect is as follows :

边栏推荐
猜你喜欢
随机推荐
[MAC] there is no source option in security and privacy
Master shell, one article is enough!
shutdown关机命令
Sift特征点提取
OSPF shunt test
如何进行探索性数据分析
8 years' experience: monthly salary of 3000 to 30000, the change of Test Engineer
应用挂了~
VMware network connection error unit network service not found
Complete one-time GC process of JVM principle
飞桨框架v2.3发布高可复用算子库PHI!重构开发范式,降本增效
JDBC入门学习(三)之事务回滚功能的实现
PHP move_ uploaded_ File failed to upload mobile pictures
Swiftui 2.0 course notes Chapter 5
The tiobe programming language ranking is an indicator of the popular trend of programming languages
HCIP 重发布实验
Open source ecology 𞓜 super practical open source license basic knowledge literacy post (Part 2)
气象绘图软件Panoply使用教程 (不定时更新)
pkav简单爆破
STP总结








