首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@media iphone 5和6查询

@media iphone 5和6查询
EN

Stack Overflow用户
提问于 2015-09-19 16:13:38
回答 1查看 1K关注 0票数 0

我试图应用字体和背景色,这取决于我是使用iphone 5还是6。查询中有重叠,所以它总是属于最后一个查询。如何将CSS应用于iphone 5和iphone 6?

代码语言:javascript
复制
/*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;
        }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-19 16:26:02

这可能对iphone 5、iphone 6和iphone 6+有帮助。

代码语言:javascript
复制
/* ----------- 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) { 

 }

来源:CSS-技巧

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32670424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档