美文网首页
H5页面窗口缩放解决方案

H5页面窗口缩放解决方案

作者: 你这个锤子 | 来源:发表于2021-10-11 10:30 被阅读0次
    窗口缩放解决方案 来自veb
    !function(){var e=document.documentElement;a=function(){var n=e.getBoundingClientRect().width;n<1200&&(n=1200),e.style.fontSize=100/1920*(n>=1920?1920:n)+"px"},c=null,window.addEventListener("resize",function(){clearTimeout(c),c=setTimeout(a,10)}),a()}()
    
    taro基于 react 的解决方案(京东)
    !function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
    

    相关文章

      网友评论

          本文标题:H5页面窗口缩放解决方案

          本文链接:https://www.haomeiwen.com/subject/idrloltx.html