当前位置:网站首页>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
边栏推荐
- Apprentissage avancé des fonctions en es6
- STM32 ADC和DMA
- LeetCode 练习——113. 路径总和 II
- Remote meter reading, switching on and off operation command
- 555电路详解
- Some properties of leetcode139 Yang Hui triangle
- Multisim--软件相关使用技巧
- PDF文档签名指南
- The variables or functions declared in the header file cannot be recognized after importing other people's projects and adding the header file
- Fiddler break point
猜你喜欢
Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
Appx代碼簽名指南
Methods of adding centerlines and centerlines in SolidWorks drawings
【STM32】STM32烧录程序后SWD无法识别器件的问题解决方法
Talking about the return format in the log, encapsulation format handling, exception handling
LLVM之父Chris Lattner:為什麼我們要重建AI基礎設施軟件
mysql插入数据创建触发器填充uuid字段值
高数_第1章空间解析几何与向量代数_向量的数量积
Some thoughts on the testing work in the process of R & D
This article explains the complex relationship between MCU, arm, muc, DSP, FPGA and embedded system
随机推荐
555电路详解
Fiddler simulates the interface test
搭建物联网硬件通信技术几种方案
Embedded background - chip
嵌入式工程师如何提高工作效率
ES6中的原型对象
Word自动生成目录的方法
ORM -- query type, association query
Use of JSON extractor originals in JMeter
JMeter loop controller and CSV data file settings are used together
XML配置文件解析与建模
@Configuration, use, principle and precautions of transmission:
ArcGIS operation: converting DWG data to SHP data
[email protected]能帮助我们快速拿到日志对象
Postman interface test I
IPv4 socket address structure
Appx代碼簽名指南
Kotlin实现微信界面切换(Fragment练习)
Several schemes of building hardware communication technology of Internet of things
Smart city construction based on GIS 3D visualization technology