如何检测响应式网页设计的屏幕尺寸? [英] How to detect screen size for responsive web design?
问题描述
我用谷歌搜索了这个并获得了一个 quirksmode网站,它可以为您提供屏幕尺寸。拉起控制台我看到 screen.width
和 screen.height
可以从窗口对象直接获得。
I googled this and got a quirksmode site that gives you your screen size. Pulling up the console I see that screen.width
and screen.height
are directly available from the window object.
我想在纯JavaScript中进行检测才能开始使用。我可以在所有设备和浏览器中使用此属性 - 移动设备,平板电脑,PC和Chrome,Safari,IE,Firefox。
I want to do the detection in pure JavaScript to get started. Can I use this property across all devices and browsers - mobile, tablet, PC and Chrome, Safari, IE, Firefox.
我不关心视口改变由于重新调整大小等等。只是屏幕的实际大小没有变化。
I don't care about the view port changing due to re-sizing etc. Just the actual size of the screen which does not change.
我希望有一个属性,我可以检查设备和浏览器。
I was hoping there was a single property I could check across devices and browsers.
推荐答案
screen.width
属性你正在寻找。
这篇关于如何检测响应式网页设计的屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!