Formatting a number as currency using CSS

前端 未结 4 947
北海茫月
北海茫月 2020-12-15 15:32

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

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 16:05

    If you're asking about number formatting in CSS (that is, parsing a number from a string and then formatting it with thousands separator, decimal separator, fixed decimal digits number etc), then no, it is impossible in CSS, and this is not what CSS was designed for.

    If you want to do any formatting, then you'd better to use XSLT. For example:

    
    
    
        
            
                $
                
            
        
    
        
            
                
            
        
    
    

提交回复
热议问题