Responsive design,意在实现不同屏幕分辨率的终端上浏览网页的不同展示方式。
html
<!--page 缩放控制-->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
css
/** iPad **/
@media only screen and (min-width: 768px) and (max-width: 1024px) {}
/** iPhone **/
@media only screen and (min-width: 320px) and (max-width: 767px) {}
/** pc **/
@media only screen and (min-width: 320px) and (max-width: 767px) {}
/** 固定宽度,使用百分比 **/
#head { width: 100% }
#content { width: 50%; }
/** 图片宽高自适应,一般设置好宽就好 **/
img { width: auto; max-width: 100%; }
/** table,建议不要增加 padding 属性,低分辨率下使用内容居中 **/
table th, table td { padding: 0 0; text-align: center; }
/** css3 用::before和::after伪元素 +content 属性来动态显示一些内容或者做其它很酷的事情 **/
@media (min-device-width:600px) {
img[data-src-600px] {
content: attr(data-src-600px, url);
}
}
@media (min-device-width:800px) {
img[data-src-800px] {
content: attr(data-src-800px, url);
}
}