index.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport"
  6. content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <meta name="format-detection" content="telephone=no">
  8. <title>鲸致生活家政服务平台</title>
  9. <script>
  10. // let html = document.documentElement;
  11. // window.rem = html.getBoundingClientRect().width / 7.5;
  12. // html.style.fontSize = window.rem + 'px';
  13. // console.log(window.rem);
  14. ;(function(win,UP){
  15. "use strict";
  16. UP.W=UP.W||{};
  17. UP.W.Rem=UP.W.Rem||{};
  18. var timer=null;
  19. var rem=12;
  20. var doc=win.document;
  21. var docEl=doc.documentElement;
  22. var visualWidth=750;
  23. var vEl=doc.querySelector('meta[name="visual-width"]');
  24. if(vEl){
  25. var vWidth=vEl.getAttribute('width');
  26. if(vWidth){
  27. visualWidth=parseInt(vWidth);
  28. }
  29. }
  30. function refreshRem(){
  31. var width=docEl.getBoundingClientRect().width;
  32. width=(width>768?visualWidth:width);
  33. rem = width/(visualWidth/100);
  34. docEl.style.fontSize=rem+'px';
  35. }
  36. win.addEventListener('resize',function(){
  37. clearTimeout(timer);
  38. timer=setTimeout(refreshRem,300);
  39. },false);
  40. win.addEventListener('pageshow',function(e){
  41. if(e.persisted){
  42. clearTimeout(timer);
  43. timer=setTimeout(refreshRem,300);
  44. }
  45. },false);
  46. if(doc.readyState=='complete'){
  47. doc.body.style.fontSize='12px';
  48. }else{
  49. doc.addEventListener('DOMContentLoader',function(e){
  50. doc.body.style.fontSize='12px';
  51. },false);
  52. }
  53. refreshRem();
  54. UP.W.Rem2px=function(d){
  55. var val=parseFloat(d)*rem;
  56. if(typeof d=='string' && d.match(/rem$/)){
  57. val +='px';
  58. }
  59. return val;
  60. };
  61. UP.W.Rem.px2rem=function(d){
  62. var val=parseFloat(d)/rem;
  63. if(typeof d==='string' && d.match(/px$/)){
  64. val +='rem';
  65. }
  66. return val;
  67. };
  68. })(window,window.UP||(window.UP={}));
  69. </script>
  70. </head>
  71. <body>
  72. <div id="app"></div>
  73. <!-- built files will be auto injected -->
  74. </body>
  75. </html>