Js dynamically sets rem to implement adaptive code for mobile fonts, jsrem
The following code describes how to dynamically set rem in Js to adapt the font on the Mobile End, so as to make a record for future convenience.
The Code is as follows:
// Set the root element font var win = window, doc = document; function setFontSize () {var winWidth = $ (window ). width (); // The number 750 is based on the actual size of your design drawing, so the value is based on the actual size of the design drawing var size = (winWidth/750) * 100; doc.doc umentElement. style. fontSize = (size <100? Size: 100) + 'px ';}; // here we give a timer to implement page loading and then set the font setTimeout (function () {// initialize setFontSize () ;}, 100 );
The above section describes how to dynamically set rem in Js to realize the adaptive code of the mobile font. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!