企业最常用的移动端px适配方案

79 阅读1分钟

废话不说,直接来。

一、下载插件 postcss-pxtorem

npm i postcss-pxtorem -D

二、根目录下新建文件 postcss.config.js

module.exports = {
  plugins: {
    'autoprefixer': {},
    'postcss-pxtorem': {
      rootValue: 37.5,
      propList: ['*']
    }
  }
}

tips: 也可以直接用vscode下载叫 px to rem 的插件,然后设置好37.5

image.png