@media iPhone 5和6查询 [英] @media iphone 5 and 6 queries

查看:52
本文介绍了@media iPhone 5和6查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据我使用的是iPhone 5还是6来应用字体和背景颜色.查询中存在重叠,因此它始终属于上一个查询.如何为iPhone 5和iPhone 6应用CSS?

 /* iPhone6肖像和风景*/@仅媒体屏幕和(最小设备宽度:375px)和(max-device-width:667px){身体 {背景颜色:红色;font-size:16px;}}/* iPhone5肖像和风景*/@仅媒体屏幕和(最小设备宽度:320px)和(最大设备宽度:568px){身体 {背景颜色:浅蓝色;font-size:12px;}} 

解决方案

这对于 iphone 5,iphone 6和iphone 6 + 可能对您有所帮助.

 /* ----------- iPhone 5和5S ----------- *//*人像和风景*/@media only屏幕和(最小设备宽度:320像素)和(最大设备宽度:568像素)和(-webkit-min-device-pixel-ratio:2){}/* 肖像 */@仅媒体屏幕和(最小设备宽度:320像素)和(最大设备宽度:568px)和(-webkit-min-device-pixel-ratio:2)和(方向:纵向){}/* 风景 */@仅媒体屏幕和(最小设备宽度:320像素)和(最大设备宽度:568px)和(-webkit-min-device-pixel-ratio:2)和(方向:风景){}/*  -  -  -  -  - - iPhone 6  -  -  -  -  - - *//*人像和风景*/@仅媒体屏幕和(最小设备宽度:375像素)和(最大设备宽度:667px)和(-webkit-min-device-pixel-ratio:2){}/* 肖像 */@仅媒体屏幕和(最小设备宽度:375像素)和(最大设备宽度:667px)和(-webkit-min-device-pixel-ratio:2)和(方向:纵向){}/* 风景 */@仅媒体屏幕和(最小设备宽度:375像素)和(最大设备宽度:667px)和(-webkit-min-device-pixel-ratio:2)和(方向:风景){}/* ----------- iPhone 6+ ----------- *//*人像和风景*/@仅媒体屏幕和(最小设备宽度:414px)和(最大设备宽度:736px)和(-webkit-min-device-pixel-ratio:3){}/* 肖像 */@仅媒体屏幕和(最小设备宽度:414px)和(最大设备宽度:736px)和(-webkit-min-device-pixel-ratio:3)和(方向:纵向){}/* 风景 */@仅媒体屏幕和(最小设备宽度:414px)和(最大设备宽度:736px)和(-webkit-min-device-pixel-ratio:3)和(方向:风景){} 

来源: CSS技巧

I am trying to apply a font and background color depending if I am using iphone 5 or 6. There is overlap in the queries, so it always falls into the last query. How do I apply CSS for iphone 5 and 6?

/*iPhone6 Portrait and Landscape*/
@media only screen 
   and (min-device-width : 375px)
   and (max-device-width : 667px) {
       body {
          background-color: red;
          font-size:16px;
       }
}

/*iPhone5 Portrait and Landscape*/
@media only screen 
    and (min-device-width : 320px)
    and (max-device-width : 568px){
        body {
            background-color: lightblue;
            font-size:12px;
        }
}

解决方案

This may be helpful for you for iphone 5, iphone 6 and iphone 6+.

/* ----------- 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 : CSS-tricks

这篇关于@media iPhone 5和6查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆