For the different size of the mobile screen, if the setting px is really a bit of impact on the user experience, on the small screen is too large, large screen too small to implement the response, so the introduction of the concept of REM.
REM is relative to the root element
In my project is the use of such a section of JS code.
(function () {varresizeevt = ' Orientationchange 'inchWindow? ' Orientationchange ': ' Resize ';varRecalc =function () {varClientWidth =Document.body.clientWidth;if(!clientwidth) {return;} Document.documentElement.style.fontSize= ten * (clientwidth/320) + ' px ';document.documentElement.style.visibility= ' Visible ';}if(!Document.documentElement.addEventListener) {return;} Window.addeventlistener (Resizeevt,recalc,false); Window.addeventlistener (' domcontentloaded ', Recalc,false);}) ();
When designed to give me psd, the measurement text for 40px,html uses REM value =40/20=2rem.
REM is not only used in units of text, but also in units of height,width,padding,marigin,line-height and so on.
Mobile-Side Settings-----REM