Reputation: 337
A SCSS function written for converting pixel to rem generates a space between value and unit. How to avoid the space. Details mentioned in the URL give below.
jsfiddle domain + /9pe5a1kx/1/
Upvotes: 0
Views: 462
Reputation: 935
Use this function:
@function px2em($px, $metric: 'em', $base-font-size: 16px) {
@if unitless($px) {
@warn "Assuming #{$px} to be in pixels, attempting to convert it into pixels.";
@return px2em($px * 1px, $metric, $base-font-size);
} @else if unit($px) == em {
@return $px;
}
@return #{($px / $base-font-size) + $metric};
}
Upvotes: 1