您当前的位置: 首页 >  ar

漏刻有时

暂无认证

  • 2浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Echarts实战案例代码(45):拼接屏字体自适应的解决方案

漏刻有时 发布时间:2020-10-21 18:39:57 ,浏览量:2

在非1920*1080,16:9模式下,字体设置成固定值,在实际显示的时候会有误差。此时,需要将字体设置成自适应。

封装函数
    function fontSize(res) {
        let docEl = document.documentElement,
                clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
        if (!clientWidth) return;
        let fontSize = 100 * (clientWidth / 1920);
        return res * fontSize;
    }

    window.addEventListener("resize", function () {
        console.log(fontSize(0.12));
    })
Echarts调用
textStyle:{
        fontSize: fontSize(0.12),
      }

Done!

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.0371s