JS根据屏幕分辨率自动调整字体大小

window.onload=font;
function font(){
   if (screen.width <1024)
       document.styleSheets[0].addRule("body","font-size:12px;");
   else if (screen.width ==1024)
         document.styleSheets[0].addRule("body","font-size:14px;");
      else if (screen.width >1024)
           document.styleSheets[0].addRule("body","font-size:16px;");
         else
             document.styleSheets[0].addRule("body","font-size:16px;");
}

你可能感兴趣的:(分辨率)