Skip to content

Commit

Permalink
Fix the rem to px calculation
Browse files Browse the repository at this point in the history
ParseInt should be done only on the rem string, not on the calculation.
so 0.3rem * 12px = 3.6px, not 3, then the Math.round is useful...
  • Loading branch information
asakurayoh committed Aug 27, 2013
1 parent 0778eea commit d26e907
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/rem.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@
},

parseCSS = function () { // replace each set of parentheses with evaluated content

var remSize;
for( var i = 0; i < foundProps.length; i++ ){
css[i] = Math.round( parseInt(foundProps[i].substr(0,foundProps[i].length-3)*fontSize, 10) ) + 'px';
remSize = parseInt(foundProps[i].substr(0,foundProps[i].length-3), 10);
css[i] = Math.round( remSize * fontSize ) + 'px';
}

loadCSS();
Expand Down

0 comments on commit d26e907

Please sign in to comment.