当前位置:网站首页>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 :

边栏推荐
- 巴比特 | 元宇宙每日必读:IP授权是NFT的破圈之路吗?它的难点在哪里?Holder该如何选择合作平台?...
- QT common Concepts-1
- AWS learning notes (I)
- Statistics of radar data in nuscenes data set
- A complete tutorial for getting started with redis: RDB persistence
- A complete tutorial for getting started with redis: AOF persistence
- Digital scrolling increases effect
- Redis introduction complete tutorial: client case analysis
- Number theory --- fast power, fast power inverse element
- Planning and design of double click hot standby layer 2 network based on ENSP firewall
猜你喜欢

Leetcode 77: combination

Install redis from zero

The panel floating with the mouse in unity can adapt to the size of text content

Qt蓝牙:QBluetoothDeviceInfo

Change your posture to do operation and maintenance! GOPs 2022 Shenzhen station highlights first!

Redis getting started complete tutorial: replication configuration

The 8 element positioning methods of selenium that you have to know are simple and practical

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?
Django database (SQLite) basic introductory tutorial

掘金量化:通过history方法获取数据,和新浪财经,雪球同用等比复权因子。不同于同花顺
随机推荐
LeetCode 77:组合
MySQL is an optimization artifact to improve the efficiency of massive data query
换个姿势做运维!GOPS 2022 · 深圳站精彩内容抢先看!
从零安装Redis
Es6中Promise的使用
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (time synchronization part)
[node learning notes] the chokidar module realizes file monitoring
Apifox, is your API interface document rolled up like this?
Cloud Mail .NET Edition
Redis入门完整教程:RDB持久化
Planning and design of double click hot standby layer 2 network based on ENSP firewall
硬件之OC、OD、推挽解释
Unity custom webgl packaging template
如何分析粉丝兴趣?
Convert widerperson dataset to Yolo format
The panel floating with the mouse in unity can adapt to the size of text content
运维管理系统有哪些特色
Have fun | latest progress of "spacecraft program" activities
Django数据库(SQlite)基本入门使用教程
Redis入门完整教程:客户端常见异常