V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wico97
V2EX  ›  问与答

js 如何检测 ppi

  •  
  •   wico97 · 2017-06-10 16:33:08 +08:00 · 1701 次点击
    这是一个创建于 2483 天前的主题,其中的信息可能已经有所发展或是发生改变。

    没找到 api 接口。看到一种方式是 function getDocumentPPI() { var elem = document.createElement('div'); elem.style.width = '1in'; document.body.appendChild(elem); var ppi = elem.offsetWidth; document.body.removeChild(elem); return ppi; } 这种靠谱吗?

    2 条回复    2017-06-10 19:04:07 +08:00
    ghostheaven
        1
    ghostheaven  
       2017-06-10 18:30:04 +08:00 via Android
    devicePixelRatio?
    wico97
        2
    wico97  
    OP
       2017-06-10 19:04:07 +08:00
    @ghostheaven 不是,是 pixels per inch
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2914 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 00:30 · PVG 08:30 · LAX 17:30 · JFK 20:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.