MrZWH / MrZWHblog

https://mrzwh.github.io/
2 stars 1 forks source link

移动Web开发 #30

Open MrZWH opened 4 years ago

MrZWH commented 4 years ago

物理像素

物理像素(physical pixel)也可以叫做设备像素(dp:device pixel)

CSS 像素

CSS 像素也可以叫做逻辑像素(logical pixel),还可以叫做设备独立像素(dip:device independent pixel)

设备像素比

PPI

视口 viewport

width=device-widthinitial-scale=1效果一样
maximum-scale=1,minimum-scale=1user-scalable=no效果一样

获取视口 viewport 宽度:

var viewWidth = document.documentElement.clientWidth || window.innerWidth || document.documentElement.getBoundingClientRect().width

不能用screen.width获取视口宽度,因为有兼容性问题,有时候会获得设备宽度

获取 dpr:window.devicePixelRatio

box-sizing

图标字体

flex 布局

容器的属性:

项目的属性:

媒体查询

媒体类型:

媒体查询中的逻辑:

媒体特征表达式:

媒体查询策略:

移动端常用单位

MrZWH commented 4 years ago

响应式布局

结构、内容和布局的概念

布局针对的是结构

栅格系统

3-1

MrZWH commented 4 years ago

移动调试和终端检测

远程调试工具Vorlon.JS

npm i -g vorlon

vorlon

多终端同步工具Browsersync

监听文件变动,自动刷新连接到页面的设备

npm i -g browser-sync

shift + 右键可在当前目录下打开命令行

启动:

browser-sync start --server --files="css/*.css,*.html"

终端检测

通过navigator.userAgent

var isMobile = navigator.userAgent.match(/android|iphone|ipad|ipod/i)