当前位置:网站首页>Uniapp adaptation problem
Uniapp adaptation problem
2022-07-07 03:05:00 【I must win this time】
Link to the original text :https://blog.csdn.net/weixin_52312684/article/details/125218453
One . Calculation formula
Design draft 1px / Base width of design draft = Frame style 1rpx / 750rpx
In other words , The page element width is in uni-app The width calculation formula in :
750 * The width of the element in the design draft / Base width of design draft
Illustrate with examples :
- If the width of the design draft is 750px, Elements A The width on the design draft is 100px, So the element A stay uni-app The width inside should be set to :750 *
100 / 750, The result is :100rpx.
- If the width of the design draft is 640px, Elements A The width on the design draft is 100px, So the element A stay uni-app The width inside should be set to :750 *
100 / 640, The result is :117rpx.
- If the width of the design draft is 375px, Elements B The width on the design draft is 200px, So the element B stay uni-app The width inside should be set to :750 *
200 / 375, The result is :400rpx.
Two . Width 750px Design draft
With the above conversion formula
750 * The width of the element in the design draft / Base width of design draft =100rpx
The blueprint is 100px Convert into 100rpx
Conclusion :
1px=1rpx
verification :
<template>
<view class="box">
<view class="box1">
</view>
</view>
</template>
<script>
export default {
}
</script>
<style>
.box{
width: 750rpx;
height: 1000rpx;
background-color: pink;
}
.box1{
width: 100rpx;
height: 100rpx;
background-color: blue;
}
</style>
Under the big screen :
The size of the box is determined by 100x100 become 50x50
explain :
Under the big screen 1px=2rpx
Come to the conclusion :
rpx It can adapt to the size of the screen Thus, the size of conceptual elements .
The actual development can be carried out directly in the mobile phone mode
Two . Width 640px Design draft
First convert :
750x100/640=117rpx
Design draft :100:117
1:1.17
in other words 1px be equal to 1.17rpx
100rpx/1.17=85.47
Usually, we usually use 750px Develop as a standard .
3、 ... and . Expand
How does the mobile end adapt ?
1. percentage 2.rem
Here we focus on rem
Suppose the design draft is 980px How to adapt
rem Is a unit, relative to the size of the current screen .
Usually use flexbox.js This plug-in divides the screen into 10 Share .
980/10=98px
That is to say 1rem be equal to 98px.
Code :
<template>
<div class="box">
</div>
</template>
<script>
export default {
name: '',
methods: {
}
}
</script>
<style scoped>
.box{
width: 1rem;
height: 1rem;
background-color: pink;
}
</style>
Four . reflection
Design draft 999px, stay 789px Do adaptation conversion into rem
The design draft is 999px.
On the mobile phone 789px Fit .
Design draft 1rem by 99.9px.
Mobile phone 1rem by 78.9px.
Come to the conclusion :
Design draft 1px be equal to :78.9px/99.9px=0.789
You can follow the 1px Equal to on the mobile phone 0.789px It's time to draw
Or use another algorithm :
边栏推荐
- How-PIL-to-Tensor
- c语言字符串排序
- Redis入门完整教程:复制配置
- NuScenes数据集关于Radar数据的统计
- The so-called consumer Internet only matches and connects industry information, and does not change the industry itself
- AWS learning notes (I)
- Andrews - multimedia programming
- sshd[12282]: fatal: matching cipher is not supported: [email protected] [preauth]
- Utilisation de la promesse dans es6
- uniapp适配问题
猜你喜欢
centerX: 用中国特色社会主义的方式打开centernet
ERROR: Could not find a version that satisfies the requirement xxxxx (from versions: none)解决办法
Redis入门完整教程:RDB持久化
tensorboard的使用
uniapp的表单验证
你知道电子招标最突出的5大好处有哪些吗?
Form validation of uniapp
MySQL --- 常用函数 - 字符串函数
Unity custom webgl packaging template
Huitong programming introductory course - 2A breakthrough
随机推荐
MATLB|具有储能的经济调度及机会约束和鲁棒优化
mos管实现主副电源自动切换电路,并且“零”压降,静态电流20uA
The so-called consumer Internet only matches and connects industry information, and does not change the industry itself
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (time synchronization part)
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
QPushButton-》函数精解
How-PIL-to-Tensor
Huitong programming introductory course - 2A breakthrough
How to design interface test cases? Teach you a few tips to draft easily
The panel floating with the mouse in unity can adapt to the size of text content
Statistics of radar data in nuscenes data set
Redis introduction complete tutorial: replication principle
QT Bluetooth: qbluetooth DeviceInfo
[2022 national tournament simulation] polygon - computational geometry, binary answer, multiplication
Unity custom webgl packaging template
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
实施MES管理系统时,哪些管理点是需要注意的
硬件之OC、OD、推挽解释
Hash table and full comments
从控制理论的角度谈数据分析