1
1
12332112021-06-11 12:33:43
css
1233211, 2021-06-11 12:33:43

How to display numbers after a dot in a smaller font?

Numbers come from the backend in this format 1234566.000910923
How can I display on the page so that the characters after the dot are in a smaller font size (just split and put in a span?)? And another question is, if the number is integer, then display 2 zeros after the dot, and if there are more than 10 characters after the dot, then cut to 10, how to do this? Thanks in advance.
60c32c171aedd416613508.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2021-06-11
@1233211

Just break it up and put it in a span (or another tag, for example, there is a small tag).

let [ int, frac ] = number.toFixed(2).split('.'); // 10 -> '10', '00'; 12.345 → '12', '35'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question