wico97
V2EX  ›  问与答

js 如何检测 ppi

  •  
  •   wico97 · Jun 10, 2017 · 2141 views
    This topic created in 3259 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
        1
    ghostheaven  
       Jun 10, 2017 via Android
    devicePixelRatio?
    wico97
        2
    wico97  
    OP
       Jun 10, 2017
    @ghostheaven 不是,是 pixels per inch
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5933 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 03:30 · PVG 11:30 · LAX 20:30 · JFK 23:30
    ♥ Do have faith in what you're doing.