'Using math.div instead of / in scss
Need to rewrite this function using math.div instead of slash. Details mentioned in the URL given below.
@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};
}
// Pixels to rem based on sass-mq
@function px2rem($px) {
@if unit($px) == rem {
@return $px;
}
@return px2em($px, 'rem');
}
@return #{($px / $base-font-size) + $metric};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|