On my page, I am facing a situation where the CSS of an element needs to be adjusted for devices like the Nexus 5X. These devices have 'Android nav bars' at the top and bottom, which can push elements around on the page.
Currently, I am using jQuery to detect and make adjustments based on device type. However, I am wondering if there is a way to achieve this using CSS media queries instead.
Here is the code snippet I am currently using:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
is_mobile = true;
}
if ($( window ).height()<window.screen.height && is_mobile==true) {
$('#my_element').css("height","46vh");
}
I was considering using CSS to compare heights directly, but it seems that 'device-height' is deprecated. Additionally, it may not be possible to directly compare the two heights in CSS anyway.
Thank you for any assistance