CSS3 syntax: (1rem = 100px for a 750px design) @media only screen and (min-width: 320px) and (max-width: 479px) { html { font-size: 42.67px !important; } } @media only screen and (min-width: 480px) and (max-width: 639px) { html { font-size: 64px !important; } } @media only screen and (min-width: 640px) and (max-width: 749px) { html { font-size: 85.34px !important; } } @media only screen and (min-width: 750px) and (max-width: 959px) { html { font-size: 100px !important; } } @media only screen and (min-width: 960px) and (max-width: 1241px) { html { font-size: 128px !important; } } @media only screen and (min-width: 1242px) { html { font-size: 165.6px !important; } } js control (zepto/jQuery) (1rem = 100px for a 750px design) function setFont() { let window_width = window.innerWidth; let font_size = parseFloat(window_width / 3.75); $('html').css('font-size', font_size); } $(window).on('resize', function () { setFont(); }); Summarize The above is what I introduced to you about media queries in CSS3 combined with rem layout to adapt to mobile phone screens. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time! |
<<: Docker solution for logging in without root privileges
>>: Detailed explanation of MySQL backup process using Xtrabackup
This article shares the specific code of JS to re...
Glass Windows What we are going to achieve today ...
1: Differences in speed and loading methods The di...
Generally speaking, the mouse is displayed as an u...
Step 1: Use Notepad to open the "my.ini"...
This article mainly introduces the implementation...
Question: In index.html, iframe introduces son.htm...
In the previous article, I introduced the detaile...
method: Take less in the actual project as an exa...
1. Single column index Choosing which columns to ...
Table of contents Math Objects Common properties ...
In actual projects, the database needs to be back...
The installation method of MySQL5.7 rpm under Lin...
Preface Usually when making h5 pages, you need to...
Sometimes you need to access some static resource...