问题
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