使用postcss-plugin-px2rem


1. 下载 npm install -s postcss-plugin-px2rem

2.在根文件夹中创建 .postcssrc.js

  module.exports = {
      "plugins": {
            "postcss-plugin-px2rem": {
              rootValue: 100,
            }
          }
  }
 
3.创建rem.js 文件 ,因为这个插件 只会转成rem,并不会设置页面字体 大小
  (function () {
      var clientWidth = document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
        if (clientWidth > 750) clientWidth = 750;
        document.documentElement.style.fontSize = clientWidth * 1 / 3.75 + "px";
        return clientWidth * 1 / 3.75;
  })();
 
4. 在main.js导入 rem.js


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM