H5使用lib-flexible时 安卓系统字体选择标准以上(大,特大)解决方案

48 阅读1分钟

源码

//本质上就是改变html的基础字体

  console.log("window.screen.width", window.screen.width);
  let html = document.getElementsByTagName("html")[0];

  console.log("html.style.fontSize", html.style.fontSize);
  console.log(
    "window.screen.width",
    parseInt(window.screen.width),
    parseInt(window.screen.width) / 10
  );

  console.log("html.style.fontSize", html.style.fontSize);
  let app = document.getElementById("app");

  console.log(
    "window.screen.width",
    parseInt(window.screen.width)
  );
  console.log("html.style.fontSize", parseInt(html.style.fontSize));
  console.log("window.screen.width", window.screen.width);
  console.log("app.scrollWidth", app.scrollWidth);
  //这里通过app 标签宽度和屏幕宽度比例调整原有的font-size
  html.style.fontSize =
    (parseInt(html.style.fontSize) * window.screen.width) /
      app.scrollWidth +
    "px";
  console.log("html.style.fontSize", html.style.fontSize);