During testing, I found out that few very large dimension device Oppo (5.5") has screen.width
equals to 360px
where as lower dimension device like iPhone 7 has screen.width
equals to 375px
.
How do I understand the nuances and measure the device width effectively?
px means pixel ie number of illuminated spots. This is only dependant on the screen resolution, not the width as a unit of length.
If you want the effective window width you can try this.
console.log($(window).width()); // returns width of browser viewport console.log($(window).height()); // returns height of browser viewport
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
For more details read this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.