flexible.min.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. !function(e, t) {
  2. if (window.mobile)
  3. return;
  4. function n() {
  5. t.body ? t.body.style.fontSize = 12 * o + "px" : t.addEventListener("DOMContentLoaded", n)
  6. }
  7. function d() {
  8. //var e = i.clientWidth / 10;
  9. //许钟文 改 将width的影响减少,height的影响增多
  10. var ratio = i.clientWidth / i.clientHeight;
  11. var a = 1;
  12. if(i.clientWidth > 560 && ratio>1.2 ) a = 0.625 / Math.pow(ratio,0.5)
  13. else if(i.clientWidth > 500 && ratio>0.8) a = ratio / Math.pow(ratio,0.7)
  14. else if(i.clientWidth > 400 && ratio>0.7) a = ratio / Math.pow(ratio,0.7)
  15. var e = i.clientWidth / 10 * a ;
  16. i.style.fontSize = e + "px"
  17. }
  18. var i = t.documentElement
  19. , o = e.devicePixelRatio || 1;
  20. if (n(),
  21. d(),
  22. e.addEventListener("resize", d),
  23. e.addEventListener("pageshow", function(e) {
  24. e.persisted && d()
  25. }),
  26. o >= 2) {
  27. var a = t.createElement("body")
  28. , s = t.createElement("div");
  29. s.style.border = ".5px solid transparent",
  30. a.appendChild(s),
  31. i.appendChild(a),
  32. 1 === s.offsetHeight && i.classList.add("hairlines"),
  33. i.removeChild(a)
  34. }
  35. }(window, document);