Search code examples
ioscssiphoneresponsive-designmedia-queries

iPhone ignores media queries


I have a problem with my media queries. I finished my responsive website and everything was ok on desktop, Android and Windows Phone devices. I asked my friends to check if it's ok on their iPhones and I got supriesed, because their iPhones (with iOS 10) are ignoring my media queries.

How it's possible? Problem is only on iPhones (5,5s,6,6s+). When I scale website in Chrome, everything is fine.

I have meta viewport tag in my head section.

This is my media query:

@media (min-device-width: 220px) and (max-device-width: 480px)
{
  /*my styling*/
}

Solution

  • @necilAlbayrak is right. Here you have correct media queries for iphones

    /* ----------- iPhone 4 and 4S ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 480px)
      and (-webkit-min-device-pixel-ratio: 2) {
    
    }
    
    /* Portrait */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 480px)
      and (-webkit-min-device-pixel-ratio: 2)
      and (orientation: portrait) {
    }
    
    /* Landscape */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 480px)
      and (-webkit-min-device-pixel-ratio: 2)
      and (orientation: landscape) {
    
    }
    
    /* ----------- iPhone 5 and 5S ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 568px)
      and (-webkit-min-device-pixel-ratio: 2) {
    
    }
    
    /* Portrait */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 568px)
      and (-webkit-min-device-pixel-ratio: 2)
      and (orientation: portrait) {
    }
    
    /* Landscape */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 568px)
      and (-webkit-min-device-pixel-ratio: 2)
      and (orientation: landscape) {
    
    }
    
    /* ----------- iPhone 6 ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 375px) 
      and (max-device-width: 667px) 
      and (-webkit-min-device-pixel-ratio: 2) { 
    
    }
    
    /* Portrait */
    @media only screen 
      and (min-device-width: 375px) 
      and (max-device-width: 667px) 
      and (-webkit-min-device-pixel-ratio: 2)
      and (orientation: portrait) { 
    
    }
    
    /* Landscape */
    @media only screen 
      and (min-device-width: 375px) 
      and (max-device-width: 667px) 
      and (-webkit-min-device-pixel-ratio: 2)
      and (orientation: landscape) { 
    
    }
    
    /* ----------- iPhone 6+ ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 414px) 
      and (max-device-width: 736px) 
      and (-webkit-min-device-pixel-ratio: 3) { 
    
    }
    
    /* Portrait */
    @media only screen 
      and (min-device-width: 414px) 
      and (max-device-width: 736px) 
      and (-webkit-min-device-pixel-ratio: 3)
      and (orientation: portrait) { 
    
    }
    
    /* Landscape */
    @media only screen 
      and (min-device-width: 414px) 
      and (max-device-width: 736px) 
      and (-webkit-min-device-pixel-ratio: 3)
      and (orientation: landscape) { 
    
    }
    

    Source: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/