Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Dec 24, 2016
2 parents 3a5b7e0 + a4e422d commit 4001935
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,20 @@ var stylus = require('gulp-stylus');
var px2rem = require('stylus-px2rem');
var autoprefixer = require('gulp-autoprefixer');
var browserslist = ['Android 2.3', 'Android >= 4', 'Chrome >= 20', 'Firefox >= 24', 'Explorer >= 8', 'iOS >= 6', 'Opera >= 12', 'Safari >= 6'];
gulp.src('./public/styl/*.styl')
.pipe(stylus({
use:[px2rem()],
compress:true
}))
.pipe(autoprefixer({
browsers: browserslist,
cascade: false
}).on('error',gutil.log))
.pipe(gulp.dest('./public/css'));


gulp.task('default', function() {
gulp.src('./public/styl/*.styl')
.pipe(stylus({
use:[px2rem()],
compress:true
}))
.pipe(autoprefixer({
browsers: browserslist,
cascade: false
}).on('error',gutil.log))
.pipe(gulp.dest('./public/css'));
});
```

index.styl
Expand Down
7 changes: 4 additions & 3 deletions lib/stylus-px2rem/mixins.styl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
兼容报告: http://caniuse.com/#feat=rem
设置html的字体大小 font-size =10px 那么此时 1rem = 10px
小于 12px 或者 75% 的字体大小 rem 确实不支持这种换算
*/
html-font-size ?= 10px;
html-font-size ?= 16px;
// style-names ?= width height min-height max-height min-width max-width border margin margin-top margin-bottom margin-left margin-right padding padding-left padding-right padding-bottom padding-top line-height;
style-names ?= "min-height" "max-height" "min-width" "max-width" "width" "height" "border" "margin" "margin-top" "margin-bottom" "margin-left" "margin-right" "padding" "padding-left" "padding-right" "padding-bottom" "padding-top" "line-height"
// value less then ignore_limit will be ignored and return the original value
Expand All @@ -20,9 +21,9 @@ px2rem(prop,values){
if(abs(value) <= px2rem_ignore_limit){
value-rem = value;
}else if(!need_normalize){
value-rem = unit(value / 16,'rem');
}else{
value-rem = unit(value / html-font-size,'rem');
}else{
value-rem = unit(value ,'rem');
}
push(values-rem,value-rem)
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylus-px2rem",
"version": "1.0.7",
"version": "1.0.9",
"description": "Stylus convert px to rem in css files with optional fallback to px.",
"main": "lib/px2rem.js",
"scripts": {
Expand Down

0 comments on commit 4001935

Please sign in to comment.