How do I find the virtual viewport/screen width using Javascript?

前端 未结 3 1786
无人及你
无人及你 2021-01-02 09:39

Is there a consistent way to determine the width of the screen and virtual viewport for mobile devices using Javascript? My target platforms are mobile Safari and Android\'

3条回答
  •  孤街浪徒
    2021-01-02 10:11

    It may help to set the scale of the viewport to 1.0 using this > tag:

    
    

    This solved a similar problem for me when when I was creating a responsive HTML/CSS layout for a mobile app (I was using CSS @media queries).

提交回复
热议问题