search
HomeWeb Front-enduni-appHow to set 750 width in uniapp

How to set 750 width in uniapp

Apr 17, 2023 am 11:26 AM

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.

  1. 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.

  1. 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.

  1. 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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you debug issues on different platforms (e.g., mobile, web)?How do you debug issues on different platforms (e.g., mobile, web)?Mar 27, 2025 pm 05:07 PM

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.

What debugging tools are available for UniApp development?What debugging tools are available for UniApp development?Mar 27, 2025 pm 05:05 PM

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

How do you perform end-to-end testing for UniApp applications?How do you perform end-to-end testing for UniApp applications?Mar 27, 2025 pm 05:04 PM

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

What are the different types of testing that you can perform in a UniApp application?What are the different types of testing that you can perform in a UniApp application?Mar 27, 2025 pm 04:59 PM

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

What are some common performance anti-patterns in UniApp?What are some common performance anti-patterns in UniApp?Mar 27, 2025 pm 04:58 PM

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.

How can you use profiling tools to identify performance bottlenecks in UniApp?How can you use profiling tools to identify performance bottlenecks in UniApp?Mar 27, 2025 pm 04:57 PM

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

How can you optimize network requests in UniApp?How can you optimize network requests in UniApp?Mar 27, 2025 pm 04:52 PM

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

How can you optimize images for web performance in UniApp?How can you optimize images for web performance in UniApp?Mar 27, 2025 pm 04:50 PM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools