All Projects → CodePlayer7 → px2rem

CodePlayer7 / px2rem

Licence: other
convert px to rem in webpack

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to px2rem

pxtorem-webpack-plugin
A webpack plugin for generating rem for stylesheet and inject auto calculate scripts.
Stars: ✭ 24 (+14.29%)
Mutual labels:  px2rem
px2rwd-intellij-plugin
用于将css中的px转换为rem/em/vw/vh值的IntelliJ插件,支持idea和webstorm
Stars: ✭ 88 (+319.05%)
Mutual labels:  px2rem
fis-postprocessor-px2rem
fis3 plugins for px2rem when we use rem for mobile flexbox
Stars: ✭ 22 (+4.76%)
Mutual labels:  px2rem
gulp-px2rem
This is a gulp plugin for node-px2rem.
Stars: ✭ 19 (-9.52%)
Mutual labels:  px2rem
px2rem.scss
Self adaption plugin for mobile development.
Stars: ✭ 18 (-14.29%)
Mutual labels:  px2rem

px2rem

npm version

开发响应式网页,尤其是手机端,常常采取rem单位。这个webpack的小loader主要是省去了每次输入长、宽、字体等都要把像素px换算成rem的麻烦, 开发时直接输入px,最后打包打包时换算为rem。

English Doc

内容列表

介绍

这是你原先的css或者js代码

// css
div {
    font-size: 14px;
    width: 100px;
}
// js 例如 react
<Page style={{ fontSize: '14px', width: '100px' }} />

采取默认的 1rem=10px 转化后变成

// css
div {
    font-size: 1.400rem;
    width: 10rem;
}
// js such as in react
<Page style={{ fontSize: '1.400rem', width: '10rem' }} />

安装

npm install webpack-px-to-rem --save-dev

使用

//in your webpack.config.js

module.exports={
   ...
    module:{
        // 或者 loaders
        rules:[
            {
                test:/\.jsx$/,
                loader:'webpack-px-to-rem',
                // 这个配置是可选的
                 query:{
                    // 1rem=npx 默认为 10
                    basePx:10,
                    // 只会转换大于min的px 默认为0
                    // 因为很小的px(比如border的1px)转换为rem后在很小的设备上结果会小于1px,有的设备就会不显示
                    min:1,
                    // 转换后的rem值保留的小数点后位数 默认为3
                    floatWidth:3
                }

            }
        ]
    }
  }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].