Skip to content

amfe-flexible

  1. 作用:根据网页宽度,设置 html 的 font-size。

  2. 安装

    sh
    npm i amfe-flexible
  3. 引入(main.js)

    javascript
    import "amfe-flexible"

postcss

  1. 作用:用于处理 css,编译 css 代码。

  2. 安装

    sh
    npm i postcss

postcss-pxtorem

  1. 作用:用于把 css 代码里所有 px 转为 rem。

  2. 安装

    sh
    npm i postcss-pxtorem@5.1.1
  3. 在根目录中创建 postcss 配置文件 postcss.config.js

    javascript
    module.exports = {
        plugins: {
            'postcss-pxtorem': {
                rootValue: 37.5,
                propList: ['*']
            }
        }
    }
  4. rootValue 由原型尺寸决定,通常情况下原型的宽度是 375px,rootValue 的值为原型宽度的十分之一。

基于 MIT 许可发布