Answer the question
In order to leave comments, you need to log in
How to round the result of a function?
Good day to all. there are two functions written in scss:
// First function
$pxbase:16;
@function emy($pxsize:$pxbase) {
@return ($pxsize/$pxbase)+em;
}
// Second function
$base:1024;
@function perc($pxl:$base) {
@return ($pxl/$base*100)+%;
}
// Task
p {
font-size: emy(23);
width: perc(573);
}
//Result
p {
font-size: 1.4375em;
width: 55.95703%;
}
Answer the question
In order to leave comments, you need to log in
The ceil() and floor() functions are described here . Usage examples can be seen by clicking on a function in the list.
Multiply by 100, round up, divide by 100. You will get rounding to hundredths.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question