《响应式Web设计:HTML5和CSS3实战(第2版)》02章

2017-11-07  本文已影响0人  Revontulet

响应式Web设计:HTML5和CSS3实战(第2版)

第二章 媒体查询

2.1 为什么响应式需要媒体查询

推荐书目

2.2 媒体查询的语法

        img {
            @media screen and (max-width: 50em);
        }

2.3 组合媒体查询

2.3.1 省略screen

2.3.2 媒体查询可以侦测的特性

特性 解释
width 视口宽度
height 视口高度
device-width 渲染表面的宽度(即屏幕宽度)
device-height 渲染表面的高度(即屏幕高度)
orientation 设备方向是垂直还是水平
aspect-ratio 视口宽高比
grid 设备基于栅格还是位图
resolution 屏幕或打印分辨率

2.4 通过媒体查询修改设计

2.4.1 任何css都可以放在媒查内

2.4.2 针对高分辨率设备的媒查

2.5 注意事项

2.5.1 使用媒查链接不同css文件

2.5.2 初步页面性能优化

2.5.3 媒查适合写在css表中

2.6 组合媒查 vs 分块摆放

        .thing {
            width: 50%;
        }
        @media (min-width: 30rem) {
            .thing {
                width: 75%;
            }
        }
        .thing2 {
            width: 50%;
        }
        @media (min-width: 30rem) {
            .thing2 {
                width: 75%;
            }
        }
        .thing {
            width: 50%;
        }
        .thing2 {
            width: 50%;
        }
        @media (min-width: 30rem) {
            .thing {
                width: 75%;
            }
            .thing2 {
                width: 75%;
            }
        }

2.7 viewpoet的meta标签

推荐使用
<meta name="viewport" content="width=device-width, initial-scale:1.0">

上一篇 下一篇

猜你喜欢

热点阅读