Just wondering if anyone knows whether it is possible to format the content of an element as currency using only CSS. It would be nice to have how the value is presented in CSS if possible, can't find anything though so I'm not holding my breath :)
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.dollars:before { content:'$'; }
</style>
</head>
<body>
Pure CSS: <span class="dollars">25153.3</span>
<br />
Ideal format: <span>$25,153.30</span>
</body>
</html>
That example comes out as:
Pure CSS: $25153.3
Ideal format: $25,153.30
Also I'm aware that it's fairly trivial using javascript - http://css-tricks.com/snippets/javascript/format-currency/.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…