当前位置:网站首页>The mobile terminal automatically adjusts the page content and font size by setting rem
The mobile terminal automatically adjusts the page content and font size by setting rem
2022-07-07 10:24:00 【weixin_ forty-two million one hundred and seventy-eight thousan】
Mobile end pass setting rem Realize automatic adjustment of page content and font size
function setRem(){
var rem = document.documentElement.clientWidth / 10; // Divide the screen width of the device into ten equal parts
document.documentElement.style.fontSize = rem + "px"; // Set the document root font to the device width 1/10
}
setRem();
window.addEventListener("resize", setRem); // add to resize event , Adjust the document root font size synchronously when the window is adjusted
window.addEventListener("pageShow", function(e) {
// add to pageShow event , Trigger... When the page is displayed
if(e.persisted) {
// Determine whether it is a page fetched from the cache ,true That is, the page fetched from the cache , Trigger the function that sets the root font
setRem();
}
})
pageShow Events and load Events like , All functions are executed when the page is loaded , By clicking on a label ,F5 Refresh and click the forward and backward buttons to refresh the page and execute load event . But Firefox has a round-trip cache , Keep page data and DOM and JS state , That is, the entire page is cached , So clicking back cannot refresh the page , So you can go through pageShow Trigger , Trigger by judging whether it is a page fetched from the cache
边栏推荐
- Fiddler simulates the interface test
- Programming features of ISP, IAP, ICP, JTAG and SWD
- C#记录日志方法
- ORM -- logical relation and & or; Sort operation, update record operation, delete record operation
- Postman interface test VI
- JMeter loop controller and CSV data file settings are used together
- [learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
- ORM -- query type, association query
- Slurm资源管理与作业调度系统安装配置
- Guid主键
猜你喜欢
每周推荐短视频:L2级有哪些我们日常中经常会用到的功能?
嵌入式背景知识-芯片
搭建物联网硬件通信技术几种方案
Some thoughts on the testing work in the process of R & D
高数_第1章空间解析几何与向量代数_向量的数量积
Socket通信原理和实践
Postman interface test VII
Use the fetch statement to obtain the repetition of the last row of cursor data
JMeter loop controller and CSV data file settings are used together
Programming features of ISP, IAP, ICP, JTAG and SWD
随机推荐
Use the fetch statement to obtain the repetition of the last row of cursor data
Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai
HDU-2196 树形DP学习笔记
Smart city construction based on GIS 3D visualization technology
Inno setup packaging and signing Guide
Why is the reflection efficiency low?
Guid primary key
Methods of adding centerlines and centerlines in SolidWorks drawings
[higherhrnet] higherhrnet detailed heat map regression code of higherhrnet
P1031 [NOIP2002 提高组] 均分纸牌
Slurm资源管理与作业调度系统安装配置
Factorial implementation of large integer classes
ORM -- query type, association query
HAL库配置通用定时器TIM触发ADC采样,然后DMA搬运到内存空间。
Appx代码签名指南
Easyexcel read write simple to use
Talking about the return format in the log, encapsulation format handling, exception handling
JMeter loop controller and CSV data file settings are used together
01 use function to approximate cosine function (15 points)
Postman tutorial - scripting