Answer the question
In order to leave comments, you need to log in
Text formatting with css. How to make gaps in the price?
There is a certain number in a certain block - the price (1-10 characters). It is desirable to place spaces between each 3 digits using css, starting from the end. For example, 1234567890 needs to be converted to 1234567890. Is it possible?
Answer the question
In order to leave comments, you need to log in
Без предварительной обработки строк (оборачивания в спаны или расстановка неразрывных пробелов) - никак.
Подобные функции в CSS обсуждались несколько лет назад на уровне идей и черновиков, но на практике не реализованы.
Если вы вручную не собираетесь оборачивать, то пожалуй никак. Зато функций на JS или PHP полно.
Wrap the necessary parts of the price in a span tag , there is no other way to do it through CSS.
Through CSS - no way. Only through JS. There is a special function for this:
Number.toLocaleString()
var str = "1234567890";
var num = 1234567890;
console.log( 'From string:', parseInt(str).toLocaleString('ru-RU') );
console.log( 'From number:', num.toLocaleString('ru-RU') );
"1 234 567 890"
"1 234 567 890"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question