Currently, I am utilizing media queries to adjust the display based on different screen sizes. However, I have encountered an issue where the screen size is not being accurately reflected in CSS. For instance, on the Nexus 4 device, the display is rendering my "480px" CSS styles, whereas in Javascript it is showing:
//Javascript displays these values:
window.innerHeight == 519
window.innerWidth == 384
//CSS is utilizing this rule:
@media screen and (orientation:portrait) and (min-width: 361px) {...}
Upon capturing a screenshot of the browser on the phone, the visible window dimensions are 768 x 1038, which is twice the size of what the actual values are showing.
I am seeking a solution to ensure that both CSS and Javascript are able to accurately reflect the resolution of the device. My goal is to serve images of varying sizes depending on the screen resolution, so that users receive the highest quality picture suited for their specific device resolution.
For instance, I have a version of the main image sized at 768 x 400. I am looking to provide this higher resolution image to the Nexus 4, rather than the scaled-down 480 x 250 image that is currently being displayed. How can I achieve this?