wico97
V2EX  ›  问与答

js 如何检测 ppi

  •  
  •   wico97 · Jun 10, 2017 · 2487 views
    This topic created in 3439 days ago, the information mentioned may be changed or developed.

    没找到 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 replies  •  2017-06-10 19:04:07 +08:00
    ghostheaven
    ghostheaven
    Jun 10, 2017 via Android
    1
    devicePixelRatio?
    wico97
    wico97
    OP
    Jun 10, 2017
    2
    @ghostheaven 不是,是 pixels per inch
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2252 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:51 · PVG 21:51 · LAX 05:51 · JFK 08:51
    ♥ Do have faith in what you're doing.