gulp-pixel2rem
gulp plugin to transform pixel to rem automatically, compatible with both pc and mobile
usage
first install package
npm install --save-dev gulp-pixel2rem
then write in your gulpfile.js
const gulp = ;const px2rem = ;gulp;
finally it will auto generate the following code in your html file
<script> var customWidth = innerWidth; if innerWidth > 480 customWidth = 480 documentdocumentElementstylefontSize = 100 * customWidth / 750 + 'px'; ; ;</script>
options
- maxWidth
the container's max width of you app - layoutWidth better be an integral multiple of the layout width of your psd or sketch file, ofter, is't set to 750