screen-resolution

How to detect the screen resolution with JavaScript?

狂风中的少年 提交于 2019-11-26 01:35:45
问题 Is there a way that works for all browsers? 回答1: original answer Yes. window.screen.availHeight window.screen.availWidth update 2017-11-10 From Tsunamis in the comments: To get the native resolution of i.e. a mobile device you have to multiply with the device pixel ratio: window.screen.width * window.devicePixelRatio and window.screen.height * window.devicePixelRatio . This will also work on desktops, which will have a ratio of 1. And from Ben in another answer: In vanilla JavaScript, this

Different resolution support android

偶尔善良 提交于 2019-11-25 22:36:32
问题 Edited Question: Mobile Resolution: I would like to design different screen dpi like following resolutions. 320x480, 480×800, 540x960, 720x1280 (Samsung S3), 1080x1920 (S4, Nexus5,Nexus 5x, Moto G4), 2560 x 1440 (Nexus 6, Nexus 6p, Samsung edge) Tablet Resolution: 480x800 (micromax) , 600x1024 (samsung tab2), 800x1280 (nexus 7), 1200x1920 (new nexus 7), 2048x1536 (nexus 9) I want to use different font sizes depending on the device display resolution. Q1) What is the best way to solve this