当前位置:网站首页>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
边栏推荐
- ORM -- query type, association query
- STM32 ADC and DMA
- IPv4 socket address structure
- P1031 [NOIP2002 提高组] 均分纸牌
- This article explains the complex relationship between MCU, arm, muc, DSP, FPGA and embedded system
- Adb 实用命令(网络包、日志、调优相关)
- 单片机(MCU)最强科普(万字总结,值得收藏)
- 深入分析ERC-4907协议的主要内容,思考此协议对NFT市场流动性意义!
- 一文讲解单片机、ARM、MUC、DSP、FPGA、嵌入式错综复杂的关系
- Google colab loads Google drive (Google drive is used in Google colab)
猜你喜欢

Pdf document signature Guide

ORM -- query type, association query

Inno setup packaging and signing Guide

Encrypt and decrypt stored procedures (SQL 2008/sql 2012)

mysql插入数据创建触发器填充uuid字段值

【acwing】786. 第k个数

【acwing】786. Number k

对存储过程进行加密和解密(SQL 2008/SQL 2012)

求方程ax^2+bx+c=0的根(C语言)

ORM model -- associated fields, abstract model classes
随机推荐
求方程ax^2+bx+c=0的根(C语言)
table宽度比tbody宽度大4px
ORM model -- creation and query of data records
Study summary of postgraduate entrance examination in September
Programming features of ISP, IAP, ICP, JTAG and SWD
Prototype object in ES6
根据设备信息进行页面跳转至移动端页面或者PC端页面
Adb 实用命令(网络包、日志、调优相关)
Postman interface test IV
Apprentissage avancé des fonctions en es6
Interface test
Vs code specifies the extension installation location
IPv4 socket address structure
Guid primary key
Multisim--软件相关使用技巧
Download Text, pictures and ab packages used by unitywebrequest Foundation
Some thoughts on the testing work in the process of R & D
搭建物联网硬件通信技术几种方案
STM32 ADC and DMA
Programming features of ISP, IAP, ICP, JTAG and SWD