Search code examples
androidcssimagenavigationmedia-queries

CSS Navigation sizing issues with Samsung/IE


I'm having a problem with the sizing of my image displays on Samsung Galaxy smartphones, and IE browsers. I'm sure there are more devices, but these are just the ones I came across now. On all apple products, I used the same techniques and they are working.

For mobile, I separated my nav into 2 rows so it displays cleaner on a smaller width screen. On PC/Laptops, it remains one row, but the images won't resize as easy as they do for macs.

Here's a JSFiddle for my Nav and Nav CSS. smart phone and other device CSS that I've started are there as well. Ill outline them below.

https://jsfiddle.net/blackRob4953/238n7ddk/1/

How do I fix the sizing for my navigation images, I.E. for this Samsung Galaxy S5?

Nav:

<nav>
<div>
    <a href="/">
        <div id="logo"><img src="/Images/7serviceLOGOblue2.png" alt="Home"/></div>
        <div id="headtag"><img src="/Images/title.png" alt="Home"/></div>
        <div id="tagline"><img src="/Images/tag_line.png" alt="Home"/></div>
    </a>
</div>
<div> 
    <a href="/" class="here">Home</a>
    <a href="/about.php">About</a>      
    <a href="/services.php">Services</a>
    <a href="/pricing.php">Pricing</a>
    <a href="/contact.php">Contact Us</a>
    <!--input id="srchbar" type="search" placeholder="Search"-->
</div>
</nav>

Samsung Galaxy S5 Nav CSS: (this is what's not working)

/* Galaxy S5 */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) { 
nav{
-webkit-flex-direction: column;
    flex-direction: column;
    margin:0;
    min-width: 360px;
    max-width: 640px;
    }
nav>div{
min-width: 360px;
max-width: 640px;
}
nav>div{
min-width: 360px;
max-width: 640px;
-webkit-justify-content: center;
justify-content: center;
}
#logo{
width:1em;
height:3em;
line-height: 0;
}
#headtag{
width:1em;
height:.1em;
line-height: 0;
}
#tagline{
width: 1em;
height:3em;
line-height: 0;
}
nav>div>a{
font-size:.4em;
margin:0 1em;
}
}

Solution

  • what i would do then instead of setting an absolute pix ratio is to have a minimum pixel ratio (for all resolutions) and go from there.

    @media screen and (min-width:320px) and (max-width:568px) and (-webkit-min-device-pixel-ratio: 1.5),  
           (-o-min-device-pixel-ratio: 3/2),  
           (min--moz-device-pixel-ratio: 1.5),  
           (min-device-pixel-ratio: 1.5) {  
    
    nav{
        -webkit-flex-direction: column;
            flex-direction: column;
            margin:0;
            }
        nav>div{
        min-width: 320px;
        max-width: 568px;
        }
        nav>div{
        min-width: 320px;
        max-width: 568px;
        -webkit-justify-content: center;
        justify-content: center;
        }
        #logo{
        width:8em;
        height:3em;
        }
        #headtag{
        width:14em;
        height:1.5em;
        }
        #tagline{
        width: 35em;
        height:3em;
        }
        nav>div>a{
        font-size:.4em;
        margin:0 1em;
        }
    }
    
    
    
    }
    
    
    
    @media screen and (min-width:360px) and (max-width:640px) and (-webkit-min-device-pixel-ratio: 1.5),  
               (-o-min-device-pixel-ratio: 3/2),  
               (min--moz-device-pixel-ratio: 1.5),  
               (min-device-pixel-ratio: 1.5) {  
    nav{
    -webkit-flex-direction: column;
        flex-direction: column;
        margin:0;
        min-width: 360px;
        max-width: 640px;
        }
    nav>div{
    min-width: 360px;
    max-width: 640px;
    }
    nav>div{
    min-width: 360px;
    max-width: 640px;
    -webkit-justify-content: center;
    justify-content: center;
    }
    #logo{
    width:1em;
    height:3em;
    line-height: 0;
    }
    #headtag{
    width:1em;
    height:.1em;
    line-height: 0;
    }
    #tagline{
    width: 1em;
    height:3em;
    line-height: 0;
    }
    nav>div>a{
    font-size:.4em;
    margin:0 1em;
    }
    
    
    }