Get native screen resolution using jQuery

我是研究僧i 提交于 2019-12-22 06:38:13

问题


I'd like to get the native screen width on a device to append scripts in the DOM. Is it possible using jQuery ?

Thanks


回答1:


window.screen.width? Source: https://developer.mozilla.org/en-US/docs/DOM/window.screen




回答2:


Sure. You can get the basic width and height using:

screen.width;
screen.height;

If required, you can also get the pixel ratio (useful if you need to also detect retina displays) by using:

window.devicePixelRatio



回答3:


You can set the width to device width with a css property:

width: device-width;



回答4:


You should use:

window.screen.availHeight
window.screen.availWidth


来源:https://stackoverflow.com/questions/14010477/get-native-screen-resolution-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!