index.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
  6. <!-- <script src="//unpkg.com/vue-ydui/dist/ydui.flexible.js"></script> -->
  7. <title>sports</title>
  8. </head>
  9. <body>
  10. <div id="app"></div>
  11. <!-- built files will be auto injected -->
  12. </body>
  13. <script>
  14. /**
  15. * YDUI 可伸缩布局方案
  16. * rem计算方式:设计图尺寸px / 100 = 实际rem 【例: 100px = 1rem,32px = .32rem】
  17. */
  18. !function (window) {
  19. /* 设计图文档宽度 */
  20. var docWidth = 100/1920;
  21. var doc = window.document,
  22. docEl = doc.documentElement,
  23. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
  24. var recalc = (function refreshRem () {
  25. var clientWidth = docEl.getBoundingClientRect().width;
  26. /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 */
  27. docEl.style.fontSize =docWidth*clientWidth + 'px';//pcduan
  28. //Math.max(Math.min(20 * (clientWidth / docWidth), 11.2), 8.55) * 9 + 'px';
  29. return refreshRem;
  30. })();
  31. /* 添加倍屏标识,安卓为1 */
  32. docEl.setAttribute('data-dpr', window.navigator.appVersion.match(/iphone/gi) ? window.devicePixelRatio : 1);
  33. if (/iP(hone|od|ad)/.test(window.navigator.userAgent)) {
  34. /* 添加IOS标识 */
  35. doc.documentElement.classList.add('ios');
  36. /* IOS8以上给html添加hairline样式,以便特殊处理 */
  37. if (parseInt(window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/)[1], 10) >= 8)
  38. doc.documentElement.classList.add('hairline');
  39. }
  40. if (!doc.addEventListener) return;
  41. window.addEventListener(resizeEvt, recalc, false);
  42. doc.addEventListener('DOMContentLoaded', recalc, false);
  43. }(window);
  44. </script>
  45. </html>