Why did you remove toFixed()? Sometimes because of division the number can have many digits after the decimal point... There is no point in setting CSS values numbers with more than 1 digit after the decimal point.