当前位置:网站首页>Mobile end adaptation scheme
Mobile end adaptation scheme
2022-06-13 05:44:00 【Thunderbolt peach】
Mobile terminal adaptive layout
- Use rem Unit of size
Scheme 1
1. Use less To configure , introduce lib-flexible plug-in unit , Or get it yourself Equipment width calculation
Use less Self configuring
- Uniform style is realized through variables
- The unified common style is extracted through mixin Mixed implementation
Self configuring js file , Calculation rem Value
- stay index.html Middle configuration , Set the font size of the root element
// Set up minimum-scale=1,maximum-scale=1 Set initial multiple // Configure whether users are allowed to zoom
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scaleable=no" />
// Bind the font size of the root element to the screen
document.documentElement.style.fontSize =
document.documentElement.clientWidth / 10 + "px";
// Screen changes reset root element font size
window.addEventListener("resize", () => {
document.documentElement.style.fontSize =
document.documentElement.clientWidth / 10 + "px";
});
less To configure
- The introduction of the file index.less mixin.less variable.less Set up rem size
Option two
Use lib-flexible plug-in unit
- 1. install
npm i lib-flexible -S - 2. First, you need to import main.js in
import "lib-flexible" - 3. Use flexible All units should use rem
webpack Help us achieve px turn rem The library of ,, be called px2rem
- 1. install
npm install px2remnpm install px2rem-loader
- 2. The plug-in configuration
- stay vue.config.js s Middle configuration
chainWebpack: (config) => {
config.module
.rule("less") // css The rules
.oneOf("vue")
.use("px2rem-loader")
.loader("px2rem-loader")
.before("postcss-loader") // this makes it work.
.options({
remUnit: 37.5, // Design Resolution size
remPrecision: 8, // rem Keep a few decimal places
}) // remUnit: 192 Representative to 1920px For the whole , If the size of the design is 750px, The value here is 75
.end();
},
3. Use
- If which style px There's no need to switch rem Words , Just add
/*no*/
.text { width: 300px; height: 300px; /*no*/ }- If which style px There's no need to switch rem Words , Just add
contrast mixin and px2rem Realization rem Transformation
Realization principle All are px/baseSize + ‘rem’
mixin Write what you need
px2rem All conversion does not need to add their own /no/
边栏推荐
- Sentinel series integrates Nacos and realizes dynamic flow control
- 890. Find and Replace Pattern
- 2021.9.29学习日志-MIME类型
- Mysql database backup and restore:
- Summary of the 11th week of sophomore year
- Set the correct width and height of the custom dialog
- A simple recursion problem of linked list
- How to Algorithm Evaluation Methods
- OpenGL mosaic (VIII)
- Small project - household income and expenditure software (2)
猜你喜欢

Service architecture diagram of Nacos series

Case - grade sorting - TreeSet set storage

安装harbor(在线|离线)

Case - recursive factorial (recursive)

890. Find and Replace Pattern

Qmessagebox in pyqt5

Automatic database backup (using Navicat)

Building a stand-alone version of Nacos series

Quartz basic use

Working principle of sentinel series (concept)
随机推荐
Standard input dialog for pyqt5 qinputdialog
MySQL installation in Linux Environment
MySQL performs an inner join on query. The query result is incorrect because the associated fields have different field types.
Browser screenshot method (long screenshot, node screenshot, designated area screenshot)
Integer tips
为什么那么多人讨厌A-Spice
MongoDB 多字段聚合Group by
Mysql database backup and restore:
Service architecture diagram of Nacos series
计算两个时间相差的天数(支持跨月、跨年)
One of PowerShell optimizations: prompt beautification
15 inclusivegateway and eventgateway of flowable gateway
13 cancelendevent of a flowable end event and compensationthrowing of a compensation event
Automatic database backup (using Navicat)
Pychart error resolution: process finished with exit code -1073741819 (0xc0000005)
Deleted the jupyter notebook in the jupyter interface by mistake
ZABBIX wechat alarm
Error: unmapped character encoding GBK
Web site learning and sorting
OpenGL Mosaic (8)