iPads和iPones的Media Queries

CSS3 Media Queries是一个强大的媒体查询功能,他的出现使用我们的站点可以随着不同的设备展现出不同的样多风格。紧随着Responsive设计的出现,Media Queries的功能是越来越得到前端人员的亲眯。

 

我也不另外,跟着这股时尚流行风,从接触到学习,紧接的到应用,对这个属性有了基本上的了解和实战经验。为了大家方便使用Media Queries,W3cplus通过互联网的搜集整理了一份CSS3 Media Queries模板。随着移动端上的应用越来越多,特别是苹果公司的系列产品型号的增加,给前端人员对Media Queries的运用带些许的麻烦。为了解决这个麻烦,在互联网上搜集了相关的资料,专门针对苹果的iPads和iPhones的Media Queries模板,希望这些模板能帮助大家减少在网上查找的时间。

iPad Media Queries

1、iPad Media Queries (所有版本,包括iPad mini)

iPads从第一代到至今,总共有五代,也就是iPad1~iPad5,以及Mini iPad。而且每一代iPad都具有相应的CSS Media Queries。这些代码能让你在的代码在iPads下更完美。

iPad (landscape和portrait)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)  { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)  { 
  /* 样式写在这里 */
}

iPad (landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
   /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
   /* 样式写在这里 */
}

iPad (portrait)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) { 
  /* 样式写在这里 */ 
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) { 
  /* 样式写在这里 */ 
}

2、iPad3和iPad4

iPad3和iPad4具有Retina屏幕技术,如果你想针对Retina屏幕使用@2x的图像,来区别普通屏幕下的显示,那么使用下面的Media Queries会让你很轻松实现。

Retina iPad (portrait 和 landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 2) { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 2) { 
  /* 样式写在这里 */
}

Retina iPad (landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) { 
  /* 样式写在这里 */
}

Retina iPad (portrait)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 2) { 
  /* 样式写在这里 */ 
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 2) { 
  /* 样式写在这里 */ 
}

3、iPad 1 和 iPad 2 Media Queries

上面的满足了高版本,可能你对细节追求的比较高,想让你的Web在低版本的iPad下也能展示的很完美,那么下面的这几段代码能帮助你。

iPad 1 有 iPad 2 (portrait 和landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (-webkit-min-device-pixel-ratio: 1){ 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (-webkit-min-device-pixel-ratio: 1){ 
  /* 样式写在这里 */
}

iPad 1 有 iPad 2 (landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */
}

iPad 1 有 iPad 2 (portrait)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) 
and (-webkit-min-device-pixel-ratio: 1) { 
  /* 样式写在这里 */ 
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) 
and (-webkit-min-device-pixel-ratio: 1) { 
  /* 样式写在这里 */ 
}

iPad mini Media Queries

使用Media Queries还能帮助我们区分iPad和iPad mini,具体的看下面的代码

iPad mini (portrait 和 landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */
}

iPad mini (landscape)

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */
}

iPad mini Resolution

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */ 
}
 only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 1)  { 
  /* 样式写在这里 */ 
}

iPad mini (portrait)

Screen Width = 768px (CSS Pixels)
Screen Height = 1024px (CSS Pixels)

Screen Width = 768px (Actual Pixels)
Screen Height = 1024px (Actual Pixels)

Device-pixel-ratio: 1

iPhone Media Queries

1、iPhone 5 Media Queries

iPhone 5 (portrait 和 landscape)

@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) { 
  /* 样式写在这里 */
}

iPhone 5 (landscape)

@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) 
and (orientation : landscape) { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) 
and (orientation : landscape) { 
  /* 样式写在这里 */
}

iPhone 5 (portrait)

@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) 
and (orientation : portrait) { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) 
and (orientation : portrait) { 
  /* 样式写在这里 */
}

2、iPhone 2G, 3G, 4, 4S Media Queries

iPhone 2G-4S (portrait 和 landscape)

@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) { 
  /* 样式写在这里 */
}
 only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) { 
  /* 样式写在这里 */
}

iPhone 2G-4S (landscape)

@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) 
and (orientation : landscape) { 
  /* 样式写这里 */
}
 only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) 
and (orientation : landscape) { 
  /* 样式写这里 */
}

iPhone 2G-4S (portrait)

@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) 
and (orientation : portrait) { 
  /* 样式写这里 */ 
}
 only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) 
and (orientation : portrait) { 
  /* 样式写这里 */ 
}

iPhone 5 Resolution

Screen Width = 320px (CSS Pixels)
Screen Height = 568px (CSS Pixels)

Screen Width = 640px (Actual Pixels)
Screen Height = 1136px (Actual Pixels)

Device-pixel-ratio: 2

iPhone 4/4S Resolution

Screen Width = 320px (CSS Pixels)
Screen Height = 480px (CSS Pixels)

Screen Width = 640px (Actual Pixels)
Screen Height = 960px (Actual Pixels)

Device-pixel-ratio: 2

iPhone 2G/3G/3GS Resolution

Screen Width = 320px (CSS Pixels)
Screen Height = 480px (CSS Pixels)

Screen Width = 320px (Actual Pixels)
Screen Height = 480px (Actual Pixels)

Device-pixel-ratio: 1

上面Media Queries主要是针对于苹果中的iPad和iPhone设备,而且使用的是px为计算单位,大家也可以将上面的px代码转换成em,详细的可以看看使用em单位创建CSS3的Media Queries

延伸阅读


▶ Walkthrough007

感谢您对上交软院ipads实验室的面试兴趣! 上交软院ipads实验室是一个致力于推动移动应用开发和创新的实验室。在面试中,我们将评估您在以下几个方面的能力和经验: 1. 移动应用开发技能:我们将询问您在移动应用开发方面的知识和技能,包括操作系统、编程语言和开发平台等。我们期望您有一定的移动应用开发经验,并熟悉常见的移动开发框架和工具。 2. 项目经历:我们将询问您在过去参与的移动应用开发项目,了解您在项目中所担任的角色和所取得的成果。请准备一些项目案例,讲述您是如何应对项目挑战和解决问题的。 3. 问题解决能力:我们将提问一些与移动应用开发相关的问题,以评估您的问题解决能力和学习能力。请保持冷静并尽量详细解答问题,展示您的思维和分析能力。 4. 团队合作能力:在实验室中,团队合作是非常重要的。我们将会询问您在过去的团队合作中的经验和角色,以及您与他人合作解决问题的能力。请分享您过去与团队成员一起完成的项目和团队合作中遇到的挑战。 在面试过程中,我们希望能够了解您的技能、经验和潜力,以及您对移动应用开发的热情和专注度。您还可以针对实验室的项目和愿景提出您的问题,以加深相互了解。 祝您面试顺利!如果您有任何疑问,请随时与我们联系。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值