In front-end development, adaptation is a very important issue. Because various screen sizes and different devices will cause the page to display differently. In uniapp we can solve this problem by setting 750 width.
Where does the 750 width come from?
750 width is a common design draft size in mobile development. Under normal circumstances, designers will set the width of the UI design draft to 750, and the height will be determined based on the actual situation. Why is the width of the design draft 750? This is because the minimum resolution of many mobile devices is 750. For example, the resolution of the iPhone XR is 828*1792, which basically meets the ratio of 1:1.78.
How to set 750 width in uniapp?
Before developing uniapp, you need to install the uni-app plug-in. After the installation is successful, start writing code.
- In the main.js file, add the following code:
import 'uni-percentage-support'
With this line of code, we introduce the uni-percentage-support plug-in into uniapp, thus The page will be adjusted accordingly.
- In the App.vue file, add the following code:
<style> html{ font-size:50vw; } </style>
Here, we use vw (window percentage unit) instead of px. Among them, 1vw is equal to 1% of the window width. Since we need to adapt based on the width of 750, we set the font size of the root element html to 50vw, so that the page can be adapted based on the width of 750.
- In the page that needs to be adapted, write the following code:
<view> <view></view> </view>
Here, we set the width of the container to 100% and the height to 100%. Internally, we set a label with a width of 37.5rem and a height of 3rem, and use margin: 0 auto to center it. Since we set the font size of html to 50vw in the App.vue file, the 37.5rem here is actually equal to 750px.
Through the above operations, the page can be adapted based on the width of 750.
Summary
In uniapp, it is a common method to adapt by setting the width of 750. By installing the uni-percentage-support plug-in and setting the font size of the HTML, we can adapt the page based on the 750 width, thereby presenting similar effects on the screens of different devices. Of course, these parameters can also be adjusted according to the actual situation to achieve the best results.
The above is the detailed content of How to set 750 width in uniapp. For more information, please follow other related articles on the PHP Chinese website!

The article discusses debugging strategies for mobile and web platforms, highlighting tools like Android Studio, Xcode, and Chrome DevTools, and techniques for consistent results across OS and performance optimization.

The article discusses debugging tools and best practices for UniApp development, focusing on tools like HBuilderX, WeChat Developer Tools, and Chrome DevTools.

The article discusses end-to-end testing for UniApp applications across multiple platforms. It covers defining test scenarios, choosing tools like Appium and Cypress, setting up environments, writing and running tests, analyzing results, and integrat

The article discusses various testing types for UniApp applications, including unit, integration, functional, UI/UX, performance, cross-platform, and security testing. It also covers ensuring cross-platform compatibility and recommends tools like Jes

The article discusses common performance anti-patterns in UniApp development, such as excessive global data use and inefficient data binding, and offers strategies to identify and mitigate these issues for better app performance.

The article discusses using profiling tools to identify and resolve performance bottlenecks in UniApp, focusing on setup, data analysis, and optimization.

The article discusses strategies for optimizing network requests in UniApp, focusing on reducing latency, implementing caching, and using monitoring tools to enhance application performance.

The article discusses optimizing images in UniApp for better web performance through compression, responsive design, lazy loading, caching, and using WebP format.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools