A
A
Alexander2016-10-08 17:22:42
css
Alexander, 2016-10-08 17:22:42

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

5 answer(s)
O
Oleg, 2016-10-08
@politon

Just like this https://jsfiddle.net/3ch8LzpL/

D
dom1n1k, 2016-10-08
@dom1n1k

Без предварительной обработки строк (оборачивания в спаны или расстановка неразрывных пробелов) - никак.
Подобные функции в CSS обсуждались несколько лет назад на уровне идей и черновиков, но на практике не реализованы.

Андрей Верх, 2016-10-08
@sadisme

Если вы вручную не собираетесь оборачивать, то пожалуй никак. Зато функций на JS или PHP полно.

Олег, 2016-10-08
@werty1001

Wrap the necessary parts of the price in a span tag , there is no other way to do it through CSS.

V
VoidVolker, 2016-10-08
@VoidVolker

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') );

Result:
"1 234 567 890"
"1 234 567 890"

jsbin.com/mazowewige/edit?js,console

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question