Display content only on mobile devices

后端 未结 4 1052
不思量自难忘°
不思量自难忘° 2021-01-27 05:46

been working with media queries recently and for some reason unknown to me this doesn\'t work?

The idea is to only display the content on mobile devices. IE phones and

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-27 06:14

    .mobileShow {display: none;} 
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 480px)
      and (-webkit-min-device-pixel-ratio: 2) {
       .mobileShow {display: block;}
    }
    
    /* ----------- iPhone 5, 5S, 5C and 5SE ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 320px) 
      and (max-device-width: 568px)
      and (-webkit-min-device-pixel-ratio: 2) {
       .mobileShow {display: block;}
    }
    /* ----------- iPhone 6, 6S, 7 and 8 ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 375px) 
      and (max-device-width: 667px) 
      and (-webkit-min-device-pixel-ratio: 2) { 
       .mobileShow {display: block;}
    }
    /* ----------- iPhone 6+, 7+ and 8+ ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 414px) 
      and (max-device-width: 736px) 
      and (-webkit-min-device-pixel-ratio: 3) { 
       .mobileShow {display: block;}
    }
    /* ----------- iPad 1, 2, Mini and Air ----------- */
    
    /* Portrait and Landscape */
    @media only screen 
      and (min-device-width: 768px) 
      and (max-device-width: 1024px) 
      and (-webkit-min-device-pixel-ratio: 1) {
       .mobileShow {display: block;}
    }
    
    

提交回复
热议问题