vm vh適配方案
- npm i postcss-px-to-viewport -save -dev
- 配置
package.json
"postcss": {
"plugins": {
"autoprefixer": {},
"postcss-px-to-viewport": {
"viewportWidth": 750,
"minPixelValue": 1
}
}
}
配置項(xiàng):
“viewportWidth”: 750, // 設(shè)計(jì)稿的寬度
“unitPrecision”: 3, // px轉(zhuǎn)成vw坏瞄、vh后小數(shù)點(diǎn)保留的位數(shù)
“minPixelValue”: 1, // 不轉(zhuǎn)化為vw的最小px值
rem 適配方案
-
postcss-pxtorem + lib-flexible
1乡数。yarn add lib-flexible
2烤宙。入口文件main.js中:import 'lib-flexible/flexible.js'
module.exports = {
plugins: {
'autoprefixer': {
browsers: ['Android >= 4.0', 'iOS >= 7']
},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*']
}
}
}