为了账号安全,请及时绑定邮箱和手机立即绑定

js获取手机在默认字体

js获取手机在默认字体

慕容708150 2019-02-06 13:12:30
嵌入到手机内的html页面,如何获取系统默认字体,大家有用到过的吗?
查看完整描述

1 回答

?
RISEBY

TA贡献1856条经验 获得超5个赞

在我andrio手机上测试有效

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Document</title>

    <style>

    

    </style>

</head>

<body>

    <div id="div">rfgdfdgdghfgsgfg</div>

    <div id="font"></div>

</body>

<script>

    window.onload = function(){

        const div = document.getElementById('div');

        const font = document.getElementById('font');

        // console.dir(div.style.fontFamily);

        function getFontFamily(elem) {

        var computedStyles = window.getComputedStyle(elem);

        console.log(computedStyles['font-family']);

        font.innerText = computedStyles['font-family'];

        }

        getFontFamily(div);

    }

    

</script>

</html>


查看完整回答
反对 回复 2019-02-20
  • 1 回答
  • 0 关注
  • 588 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号