环境:webpack:3.0+; vue:2.0+
方法:使用 postcss-pxtorem插件
步骤一:
复制代码
1npm i postcss-pxtorem -D
步骤二:在package.json文件中postcss添加配置
复制代码
1
2
3
4
5
6
7
8
9
10
11"postcss": { "plugins": { "autoprefixer": {}, "postcss-pxtorem": { "rootValue": 37.5, "propList": [ "*" ] } } }
Tip:如果某些css不想被转为rem,如下写法
复制代码
1
2.test{width:10px} //被转为rem .test{width:10PX} //不转为rem,因为css不分大小写,PX会被当做px处理,postcss-pxtorem只转换小写的px
最后
以上就是羞涩雪糕最近收集整理的关于H5 vue 移动端px自动转换rem的全部内容,更多相关H5内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复