Responsive设计在现代Web设计中可谓是越来越流行,但很同学们并未理解其真正的设计概念,往往把Responsive视为一种自适应布局。当然有很多同学也在尝试动写Responsive的案例,但如何取其断点左右纠结,如何设置哪几个断点?又从何入手?
Responsive中的断点都依赖于CSS3的Media Queries来决断。曾在CSS3 Media Queries模板、使用em单位创建CSS3的Media Queries和iPads和iPones的Media Queries有过这方面的介绍。今天特意根据一些Responsive框架整理了一些常见的Media Queries片段,以供大家参考:
在这里主要分成三类:移动端、PC端以及一些常见的响应式框架的Media Queries片段。
screen (device-aspect- /) {} 或者: screen (device- px) (device- px) (-webkit-device-pixel- ){}
only screen (min-device-width px) (max-device-width px){ }
only screen (min-device-width px) (max-device-width px) (orientation landscape){ }
only screen (min-device-width px) (max-device-width px) (orientation portrait){ }
only screen (-webkit-min-device-pixel-ratio ), only screen (min-device-pixel-ratio ) {}
screen (device- px) (device- px) (-webkit-device-pixel- ){}
/ screen (max-device-width: px) {} / screen (max-device-width: px) {}
screen (max-device- px) {}
only screen (-webkit-device-pixel- ) {}
screen (device- px) (device- px) (-webkit-min-device-pixel- ) (-webkit-max-device-pixel- ) {}
only screen (-webkit-device-pixel- ) {}
screen (device- px) (device- px) (-webkit-device-pixel- ) {}
/ (max-device-width: px) (orientation: landscape) {} / (max-device-width: px) (orientation: portrait) {}
only screen (min-device-width px) (max-device-width px){ }
only screen (min-device-width px) (max-device-width px) (orientation landscape){ }
only screen (min-device-width px) (max-device-width px) (orientation portrait){ }
only screen (min-device-width px) (max-device-width px) (-webkit-min-device-pixel- ){ }
only screen (min-device-width px) (max-device-width px) (orientation landscape) (-webkit-min-device-pixel- ){ }
only screen (min-device-width px) (max-device-width px) (orientation portrait) (-webkit-min-device-pixel- ){ }
only screen (min-device-width px) (max-device-width px) (-webkit-min-device-pixel- ){ }
only screen (min-device-width px) (max-device-width px) (orientation landscape) (-webkit-min-device-pixel- ){ }
only screen (min-device-width px) (max-device-width px) (orientation portrait) (-webkit-min-device-pixel- ) { }
screen (max- px) {}
screen (max- px) {}
screen (max- px) {}
screen (max- px) {}
screen (max- px) {}
除了上面的常见Media Queries片段之外,下面的网站还提供了一些其他的片段:
/:http:5boilerplate.com/ only screen (min-width : px) (max-width : px) { } only screen (min-width : px) { } only screen (max-width : px) { } only screen (min-width : px) (max-width : px) { } only screen (min-width : px) (max-width : px) (orientation : landscape) { } only screen (min-width : px) (max-width : px) (orientation : portrait) { } only screen (min-width : px) { } only screen (min-width : px) { }only screen (-webkit-min-device-pixel-ratio : ), only screen (min-device-pixel-ratio : ) { }
{ ... } { ... } { ... } { ... }
/:http:.zurb.com/ only screen { } only screen (min-width: px) {} only screen (min-width: px) {} only screen (min-width: px) {} only screen (orientation: landscape) {} only screen (orientation: portrait) {}
/:http:.getskeleton.com only screen (max-width: px) {} only screen (min-width: px) (max-width: px) {} only screen (max-width: px) {} only screen (min-width: px) (max-width: px) {} only screen (max-width: px) {}
/:http:.com/ screen (max-width: em){} screen (min-width: em) (max-width: em), screen (min-width: em) (max-width: em), screen (min-width: em) (max-width: em), screen (min-width: em){} screen (min-width: em) (max-width: em), screen (min-width: em){} screen (min-width: em){} screen (min-width: em){} screen (min-width: em){} screen (min-width: em){} screen (min-width: em) (max-width: em){} screen (min-width: em){}
{}{}{}{}{}
/:http:.com/ only screen (min-width: px) (max-width: px) {} only screen (max-width: px) {} / Mobile Layout: px (em) only screen (min-width: px) (max-width: px) {}
/:http:.com/ screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {} screen (min-width: em) {}
/:http:.com/ only screen (min-width: px) {} only screen (min-width: px) {} only screen (min-width: px) {} only screen (min-width: px) {} only screen (min-width: px) {} only screen (min-width: px) {} only screen (min-width: px) {}
{ }{ }{ }{ }{ }{ }
{ }{ }{ }
/:http:.com/ only screen (max-width: px) {} only screen (min-width: px) (max-width: px) {} only screen (max-width: px) {} only screen (min-width: px) (max-width: px) {} only screen (max-width: px) {}
{} {} {} {} {}
本文搜集的是Media Queries在各种设备下的代码片段,希望这些片段能帮大家更好的理解Responsive断点的设置。如果大家有更好的方案,希望能在评论中分享。
前提设置body的字体为100%。其具有一个简单的计算公式:100% = 16px = 1em = 14pt
/ = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width : em){ } / = px screen (max-width : em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / = px screen (max-width: em){ } / Density (-webkit-min-device-pixel-ratio: ),(min-resolution: dpi){ } / Density (-webkit-min-device-pixel-ratio: ),(min-resolution: dpi){ } / Density (-webkit-min-device-pixel-ratio: ),(min-resolution: dpi){ } / Density (-webkit-min-device-pixel-ratio: ),(min-resolution: dpi){ } / Resolution dpi (min-resolution: dpi){ } / Resolution dpi (min-resolution:dpi){ } / Resolution dpi (min-resolution:dpi){ } / Resolution dpi (resolution:dpi){ }
出处:http://www.w3cplus.com/css3/media-query-snippets.html