CSS3 Media Queries片段

在这里主要分成三类:移动端、PC端以及一些常见的响应式框架的Media Queries片段。

移动端Media Queries片段

iPhone5

@media screen and (device-aspect-ratio: 40/71) {}
或者:
@media screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2){}

iPhone 5 In Portrait & Landscape

@media only screen
and (min-device-width : 320px)
and (max-device-width : 568px){
// CSS Style
}

iPhone 5 In Landscape

@media only screen
and (min-device-width : 320px)
and (max-device-width : 568px)
and (orientation : landscape){
// CSS Style
}

iPhone 5 In Portrait

@media only screen
and (min-device-width : 320px)
and (max-device-width : 568px)
and (orientation : portrait){
// CSS Style
}

iPone4

@media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {}

iPhone 3G

@media screen and (device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1){}

iPhone

/*Landscape*/
@media screen and (max-device-width: 480px) {} /*Portrait*/
@media screen and (max-device-width: 320px) {}

Blackberry Torch

@media screen and (max-device-width: 480px) {}

Samsung S3

@media only screen and (-webkit-device-pixel-ratio: 2) {}

Google Nexus 7

@media screen and (device-width: 600px) and (device-height: 905px) and (-webkit-min-device-pixel-ratio: 1.331) and (-webkit-max-device-pixel-ratio: 1.332) {}

Samsung Galaxy S3

@media only screen and (-webkit-device-pixel-ratio: 2) {}

Samsung Galaxy S2

@media screen and (device-width: 320px) and (device-height: 533px) and (-webkit-device-pixel-ratio: 1.5) {}

Galaxy Tab 10.1

/*Landscape*/
@media (max-device-width: 1280px) and (orientation: landscape) {} /*Portrait*/
@media (max-device-width: 800px) and (orientation: portrait) {}

iPad In Portrait & Landscape

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px){
// CSS Styles
}

iPad In Landscape

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape){
// CSS Styles
}

iPad In Portrait

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait){
// CSS Styles
}

Retina iPad In Portrait & Landscape

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 2){
// CSS Styles
}

Retina iPad in landscape

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2){
// CSS Styles
}

Retina iPad in portrait

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 2){
// CSS Styles
}

iPad Mini In Portrait & Landscape

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 1){
// CSS Style
}

iPad Mini In Landscape

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1){
// CSS Style
}

iPad Mini In Portrait

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 1) {
// CSS Style
}

桌面端

320px

@media screen and (max-width: 320px) {}

640px

@media screen and (max-width: 640px) {}

800px

@media screen and (max-width: 800px) {}

1024px

@media screen and (max-width: 1024px) {}

1028px

@media screen and (max-width: 1028px) {}

除了上面的常见Media Queries片段之外,下面的网站还提供了一些其他的片段:

框架Media Queries片段

Boilerplate

/*URL:http://html5boilerplate.com/*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-width : 768px)
and (max-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
@media only screen
and (min-width : 768px)
and (max-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
@media only screen
and (min-width : 768px)
and (max-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}

Bootstrap的Media Queries

/*URL:http://twitter.github.com/bootstrap*/
/* Large desktop */
@media (min-width: 1200px) { ... } /* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 979px) { ... } /* Landscape phone to portrait tablet */
@media (max-width: 767px) { ... } /* Landscape phones and down */
@media (max-width: 480px) { ... }

Foundation的Media Queries

/*URL:http://foundation.zurb.com/*/
/* We use this media query to add styles to any device that supports media queries */
@media only screen { } /* Used to alter styles for screens at least 768px wide. This is where the grid changes. */
@media only screen and (min-width: 768px) {} /* Used to alter styles for screens at least 1280px wide. */
@media only screen and (min-width: 1280px) {} /* Used to alter styles for screens at least 1440px wide. */
@media only screen and (min-width: 1440px) {} /* Apply styles to screens in landscape orientation */
@media only screen and (orientation: landscape) {} /* Apply styles to screens in portrait orientation */
@media only screen and (orientation: portrait) {}

Skeleton的Media Queries

/*URL:http://www.getskeleton.com*/
/* Smaller than standard 960 (devices and browsers) */
@media only screen and (max-width: 959px) {} /* Tablet Portrait size to standard 960 (devices and browsers) */
@media only screen and (min-width: 768px) and (max-width: 959px) {} /* All Mobile Sizes (devices and browser) */
@media only screen and (max-width: 767px) {} /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
@media only screen and (min-width: 480px) and (max-width: 767px) {} /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
@media only screen and (max-width: 479px) {}

FRAMELESS的Media Queries

/*URL:http://framelessgrid.com/*/
@media screen and (max-width: 16.875em){}
@media screen and (min-width: 32.5em) and (max-width: 37.4375em),
screen and (min-width: 45em) and (max-width: 56.9375em),
screen and (min-width: 77.5em) and (max-width: 102.4375em),
screen and (min-width: 135em){}
@media screen and (min-width: 102.5em) and (max-width: 117.9375em),
screen and (min-width: 150em){}
@media screen and (min-width: 15em){}
@media screen and (min-width: 30em){}
@media screen and (min-width: 37.5em){}
@media screen and (min-width: 57em){}
@media screen and (min-width: 57em) and (max-width: 117.9375em){}
@media screen and (min-width: 118em){}

Susy的Media Queries

/*URL:http://susy.oddbird.net/*/
@media (min-width: 29em) {} @media (min-width: 30em) and (max-width: 60em) {} @media (min-width: 119em) {} @media (min-width: 33.75em) and (max-width: 67.5em) {} @media (min-width: 33.75em) and (max-width: 67.5em) {}

Less Framework 4

/*URL:http://lessframework.com/*/
@media only screen and (min-width: 768px) and (max-width: 991px) {} /* Mobile Layout: 320px (20em). */
@media only screen and (max-width: 767px) {} /*Wide Mobile Layout: 480px (30em)*/
@media only screen and (min-width: 480px) and (max-width: 767px) {}

Golden Grid System的Media Queries

/*URL:http://goldengridsystem.com/*/
/* @media screen and (min-width: 640px) */
@media screen and (min-width: 40em) {} /* @media screen and (min-width: 720px) */
@media screen and (min-width: 45em) {} /* @media screen and (min-width: 888px) */
@media screen and (min-width: 55.5em) {} /* @media screen and (min-width: 984px) */
@media screen and (min-width: 61.5em) {} /* @media screen and (min-width: 1200px) */
@media screen and (min-width: 75em) {} /* @media screen and (min-width: 1392px) */
@media screen and (min-width: 87em) {} /* @media screen and (min-width: 1680px) */
@media screen and (min-width: 105em) {} /* @media screen and (min-width: 1872px) */
@media screen and (min-width: 117em) {} /* @media screen and (min-width: 2080px) */
@media screen and (min-width: 130em) {}

Fluid baseline的Media Queries

/*URL:http://fluidbaselinegrid.com/*/
/* MOBILE PORTRAIT */
@media only screen and (min-width: 320px) {} /* MOBILE LANDSCAPE */
@media only screen and (min-width: 480px) {} /* SMALL TABLET */
@media only screen and (min-width: 600px) {} /* TABLET/NETBOOK */
@media only screen and (min-width: 768px) {} /* LANDSCAPE TABLET/NETBOOK/LAPTOP */
@media only screen and (min-width: 1024px) {} @media only screen and (min-width: 1280px) {} /* WIDESCREEN */
/* Increased body size for legibility */
@media only screen and (min-width: 1400px) {}

320andUP

/*URL:http://stuffandnonsense.co.uk/projects/320andup*/
@media only screen and (min-width: 480px) {
/* 480 */
} @media only screen and (min-width: 600px) {
/* 600 */
} @media only screen and (min-width: 768px) {
/* 768*/
} @media only screen and (min-width: 992px) {
/* 992*/
} @media only screen and (min-width: 1382px) {
/* 1382 */ } @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
/* 2x*/
}

Gridless

/* URL:http://thatcoolguy.github.com/gridless-boilerplate/ */

@media only screen and (min-width: 480px) {
/* Wide mobile (480px+) styles go here */
} @media only screen and (min-width: 768px) {
/* Tablets/netbooks (768px+) styles go here */
} @media only screen and (min-width: 1024px) {
/* Desktops (1024px+) styles go here */
}

TotanTHEMES

/*URL:http://titanthemes.com/*/

/* Smaller than standard 960 (devices and browsers) */
@media only screen and (max-width: 959px) {} /* Tablet Portrait size to standard 960 (devices and browsers) */
@media only screen and (min-width: 768px) and (max-width: 989px) {} /* All Mobile Sizes (devices and browser) */
@media only screen and (max-width: 767px) {} /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
@media only screen and (min-width: 480px) and (max-width: 767px) {} /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
@media only screen and (max-width: 479px) {}

Responsive Grid System

/*URL:http://responsive.gs/*/
@media (max-width: 480px) {} @media (min-width: 480px) and (max-width: 768px) {} @media (min-width: 768px) {} @media (min-width: 1024px) {} @media (min-width: 1200px) {}

本文搜集的是Media Queries在各种设备下的代码片段,希望这些片段能帮大家更好的理解Responsive断点的设置。如果大家有更好的方案,希望能在评论中分享。

2014年04月19日更新

基于视窗宽度的媒体查询断点设置

前提设置body的字体为100%。其具有一个简单的计算公式:100% = 16px = 1em = 14pt

/*Viewport = 1920px*/
@media screen and (max-width: 120em){ }
/*Viewport = 1680px*/
@media screen and (max-width: 105em){ }
/*Viewport = 1400px*/
@media screen and (max-width: 87.5em){ }
/*Viewport = 1200px*/
@media screen and (max-width: 75em){ }
/*Viewport = 1024px*/
@media screen and (max-width: 64em){ }
/*Viewport = 960px*/
@media screen and (max-width: 60em){ }
/*Viewport = 800px*/
@media screen and (max-width : 50em){ } /*Viewport = 768px*/
@media screen and (max-width : 48em){ } /*Viewport = 600px*/
@media screen and (max-width: 37.5em){ } /*Viewport = 480px*/
@media screen and (max-width: 30em){
} /*Viewport = 320px*/
@media screen and (max-width: 20em){ } /*Viewport = 240px*/
@media screen and (max-width: 15em){ } /*
High Resolution/Retina Display Media Queries
*/
/*Pixel Density 3*/
@media(-webkit-min-device-pixel-ratio: 3),(min-resolution: 192dpi){ }
/*Pixel Density 2*/
@media(-webkit-min-device-pixel-ratio: 2),(min-resolution: 192dpi){ }
/*Pixel Density 1.5*/
@media(-webkit-min-device-pixel-ratio: 1.5),(min-resolution: 124.8dpi){ }
/*Pixel Density 1.25*/
@media(-webkit-min-device-pixel-ratio: 1.25),(min-resolution: 120dpi){ } /*
Printed Style Media Queries
*/
/*Print Resolution 300 dpi*/
@media print and (min-resolution: 300dpi){ } /*Print Resolution 144 dpi*/
@media print and (min-resolution:144dpi){ } /*Print Resolution 96 dpi*/
@media print and (min-resolution:96dpi){ } /*Print Resolution 72 dpi*/
@media print and (resolution:72dpi){ }

更新:iPhone6

@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation : portrait) {
/*iPhone 6 Portrait*/
} @media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation : landscape) {
/*iPhone 6 landscape*/
} @media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (orientation : portrait) {
/*iPhone 6+ Portrait*/
} @media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (orientation : landscape) {
/*iPhone 6+ landscape*/
} @media only screen and (max-device-width: 640px), only screen and (max-device-width: 667px), only screen and (max-width: 480px){
/*iPhone 6 and iPhone 6+ portrait and landscape*/
} @media only screen and (max-device-width: 640px), only screen and (max-device-width: 667px), only screen and (max-width: 480px) and (orientation : portrait){
/*iPhone 6 and iPhone 6+ portrait*/
} @media only screen and (max-device-width: 640px), only screen and (max-device-width: 667px), only screen and (max-width: 480px) and (orientation : landscape){
/*iPhone 6 and iPhone 6+ landscape*/
}

如需转载,烦请注明出处:http://www.w3cplus.com/css3/media-query-snippets.html

CSS3 Media Queries 片段的更多相关文章

  1. CSS3教程:Responsive框架常见的Media Queries片段

    CSS3 Media Queries片段在这里主要分成三类:移动端.PC端以及一些常见的响应式框架的Media Queries片段.移动端Media Queries片段iPhone5@media sc ...

  2. CSS3 Media Queries 实现响应式设计

    在 CSS2 中,你可以为不同的媒介设备(如屏幕.打印机)指定专用的样式表,而现在借助 CSS3 的 Media Queries 特性,可以更为有效的实现这个功能.你可以为媒介类型添加某些条件,检测设 ...

  3. 【CSS3 入门教程系列】CSS3 Media Queries 实现响应式设计

    在 CSS2 中,你可以为不同的媒介设备(如屏幕.打印机)指定专用的样式表,而现在借助 CSS3 的 Media Queries 特性,可以更为有效的实现这个功能.你可以为媒介类型添加某些条件,检测设 ...

  4. HTML5实践 -- 使用CSS3 Media Queries实现响应式设计

    CSS3 Media用法介绍:http://www.w3cplus.com/content/css3-media-queries 转载请注明原创地址:http://www.cnblogs.com/so ...

  5. CSS3 Media Queries模板

    使用max-width @media screen and (max-width: 600px) { //你的样式放在这里.... } 使用min-width @media screen and (m ...

  6. CSS3 Media Queries在iPhone4和iPad上的运用

    CSS3 Media Queries的介绍在W3CPlus上的介绍已有好几篇文章了,但自己碰到的问题与解决的文章还是相对的较少.前几天在<修复iPhone上submit按钮bug>上介绍了 ...

  7. Css3 Media Queries移动页面的样式和图片的适配问题(转)

    CSS3 Media Queries 摘自:http://www.w3cplus.com/content/css3-media-queries Media Queries直译过来就是“媒体查询”,在我 ...

  8. 移动终端学习1:css3 Media Queries简介

    移动终端学习之1:css3 Media Queries简介 1.简介 这篇文章写的不错,我就不重复了,来个链接:http://www.w3cplus.com/content/css3-media-qu ...

  9. 移动终端学习一:css3 Media Queries简介

    移动终端学习之一 css3 Media Queries简介 1.简介 别人写过的我就不重复了,来个链接:http://www.w3cplus.com/content/css3-media-querie ...

随机推荐

  1. 【代码笔记】iOS-两个滚动条,上下都能滑动

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  2. 【代码笔记】iOS-两个时间字符串的比较

    一,效果图. 二,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the ...

  3. Socket的简单使用

    一.Socket: Socket又称”套接字" 网络上的两个程序通过一个双向的通信链接实现数据的交换,这个连接的一端成为一个socket 应用程序通常通过”套接字”向网络发出请求或者应答网络 ...

  4. iis中限制访问某个文件或某个类型的文件配置方法

    Note:此处不是权限设置问题,此处不是权限设置问题,此处不是权限设置问题!只是出于数据或者网络安全,禁止扫描工具直接扫描到某些包含敏感信息的文件,尤其比如日志.配置等 默认ASP.NET已经考虑到了 ...

  5. Web API与国际化

    软件国际化是在软件设计和文档开发过程中,使得功能和代码设计能处理多种语言和文化习俗,在创建不同语言版本时,不需要重新设计源程序代码的软件工程方法.这在很多成熟的软件开发平台中非常常见.对于.net开发 ...

  6. NuGet学习笔记1——初识NuGet及快速安装使用

    关于NuGet园子里已经有不少介绍及使用经验,本文仅作为自己研究学习NuGet一个记录. 初次认识NuGet是在去年把项目升级为MVC3的时候,当时看到工具菜单多一项Library Package M ...

  7. ORA-12154 & TNS-03505 案例分享

    下面介绍一个工作中遇到的案例场景,应用服务器连接数据库出现"ORA-12154: TNS: 无法解析指定的连接标识符".一般情况下ORA-12541错误是很容易排除的,但是这次遇到 ...

  8. 编译hadoop2.6.0

    具体情况比较曲折:hadoop2.6.0编译不过 错误如下: 这个kms模块始终编译不过,最后得出结论国内的aliyun maven仓库有问题, 在编译hadoop2.2.0 可以通过,因为这个版本的 ...

  9. Tomcat:基于Apache+Tomcat的集群搭建

    根据Tomcat的官方文档说明可以知道,使用Tomcat配置集群需要与其它Web Server配合使用才可以完成,典型的有Apache和IIS. 这里就使用Apache+Tomcat方式来完成基于To ...

  10. SharePoint Content Database简介

    SharePoint作为微软主打的企业Portal平台,功能强大,使用简单,非常的方便.对于很多关系数据,我们可以使用自定义列表来维护,如果是非关系数据,可以使用文档库来维护.另外还可以在上面进行版本 ...